当前位置:网站首页>Exercise 8-7 string sorting
Exercise 8-7 string sorting
2022-07-03 14:09:00 【ᯤ⁹ᴳ⁺ ·】
exercises 8-7 String sort (20 branch )
This question requires the preparation of procedures , Read in 5 A string , Output in order of small to large .
Input format :
Input is space delimited 5 Non empty strings , Each string does not contain spaces 、 tabs 、 Blank characters such as line breaks , The length is less than 80.
Output format :
Output the sorted results in the following format :
After sorted:
One string per line
sample input :
red yellow blue black white
sample output :
After sorted:
black
blue
red
white
yellow
#include<stdio.h>
#include<string.h>
int main()
{
char a[5][81];
char b[1][81];
for(int i=0;i<5;i++){
scanf("%s",a[i]);
}
for(int i=0;i<4;i++){
for(int j=i+1;j<5;j++){
if(strcmp(a[i],a[j])>0){
strcpy(b[0],a[i]);
strcpy(a[i],a[j]);
strcpy(a[j],b[0]);
}
}
}
printf("After sorted:\n");
for(int i=0;i<5;i++){
printf("%s\n",a[i]);
}
return 0;
}
边栏推荐
- 使用vscode查看Hex或UTF-8编码
- Using registered classes to realize specific type matching function template
- UiO-66-COOH装载苯达莫司汀|羟基磷灰石( HA) 包裹MIL-53(Fe)纳米粒子|装载黄芩苷锰基金属有机骨架材料
- Invalid Z-index problem
- Function calling convention
- The small project (servlet+jsp+mysql+el+jstl) completes a servlet with login function, with the operation of adding, deleting, modifying and querying. Realize login authentication, prevent illegal log
- Folic acid modified metal organic framework (zif-8) baicalin loaded metal organic framework composite magnetic material (AU- [email
- 金属有机骨架(MOFs)抗肿瘤药载体|PCN-223装载甲硝唑|UiO-66包载盐酸环丙沙星([email protected])
- [acnoi2022] guess numbers
- QT learning 20 standard dialog box in QT (middle)
猜你喜欢
FPGA测试方法以Mentor工具为例
[技術發展-24]:現有物聯網通信技術特點
Global event bus
GoLand 2021.1: rename the go project
Qt学习23 布局管理器(二)
The small project (servlet+jsp+mysql+el+jstl) completes a servlet with login function, with the operation of adding, deleting, modifying and querying. Realize login authentication, prevent illegal log
Installation impression notes
FPGA test method takes mentor tool as an example
Metal organic framework MOFs loaded with non steroidal anti-inflammatory drugs | zif-8 wrapped Prussian blue loaded quercetin (preparation method)
Configure stylelint
随机推荐
JS first summary
JS general form submission 1-onsubmit
Qt学习25 布局管理器(四)
Qt学习24 布局管理器(三)
Qt学习20 Qt 中的标准对话框(中)
小项目(servelt+jsp+mysql+EL+JSTL)完成一个登录功能的Servlet,具有增删改查的操作。实现登录身份验证,防止非法登录,防止多点登录,记住用户名密码功能。
Implementation of Muduo accept connection, disconnection and sending data
“又土又穷”的草根高校,凭什么被称为“东北小清华”?
How to promote the progress of project collaboration | community essay solicitation
Qt学习17 对话框及其类型
How to bold text in AI
GoLand 2021.2 configure go (go1.17.6)
[ACNOI2022]猜数
allegro,orcad, net alias,port,off-page connector之间的异同点和如何选取
JS download files through URL links
【吉林大学】考研初试复试资料分享
Rasp implementation of PHP
Implementation of Muduo asynchronous logging
Duet date picker (time plug-in that can manually enter the date)
js 2023. String pair equal to the target string after connection