当前位置:网站首页>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;
}

边栏推荐
- 如何使用lxml判断网站公告是否更新
- Scroll detection, so that the content in the lower right corner is not displayed at the top of the page, but is displayed as the mouse slides
- Golang - command line tool Cobra
- 金属有机骨架(MOFs)抗肿瘤药载体|PCN-223装载甲硝唑|UiO-66包载盐酸环丙沙星([email protected])
- Duet date picker (time plug-in that can manually enter the date)
- Metal organic framework (MOFs) antitumor drug carrier | pcn-223 loaded with metronidazole | uio-66 loaded with ciprofloxacin hydrochloride( Go language unit test 5: go language uses go sqlmock and Gorm to do database query mock
- Go language web development series 30: gin: grouping by version for routing
- [combinatorics] permutation and combination (examples of combinatorial number of multiple sets | three counting models | selection problem | combinatorial problem of multiple sets | nonnegative intege
- Use vscode to view hex or UTF-8 codes
猜你喜欢

QT learning 21 standard dialog box in QT (Part 2)
![[技術發展-24]:現有物聯網通信技術特點](/img/f3/a219fe8e7438b8974d2226b4c3d4a4.png)
[技術發展-24]:現有物聯網通信技術特點
[email protected](Fe)|甘草次酸修饰金属有机框架材料UiO-66-NH2(简称UiO-66-NH2-GA)"/>MIL-100( Fe) 包裹小分子阿司匹林形成[email protected](Fe)|甘草次酸修饰金属有机框架材料UiO-66-NH2(简称UiO-66-NH2-GA)

使用vscode查看Hex或UTF-8编码

Global event bus

JS input number and standard digit number are compared. The problem of adding 0 to 0

Solve MySQL 1045 access denied for user 'root' @ 'localhost' (using password: yes)

jvm-对象生命周期

Qt学习19 Qt 中的标准对话框(上)

jvm-运行时数据区
随机推荐
QT learning 22 layout manager (I)
Richview trvstyle liststyle list style (bullet number)
Interface for querying IP home
Programmable logic device software testing
JS general form submission 1-onsubmit
jvm-运行时数据区
Scroll detection, so that the content in the lower right corner is not displayed at the top of the page, but is displayed as the mouse slides
叶酸修饰的金属-有机骨架(ZIF-8)载黄芩苷|金属有机骨架复合磁性材料([email protected])|制备路线
selenium 浏览器(1)
Use vscode to view hex or UTF-8 codes
交联环糊精金属有机骨架负载甲氨蝶呤缓释微粒|金属-有机多孔材料UiO-66负载黄酮苷类药物|齐岳
Collection of mobile adaptation related articles
Windos creates Cordova prompt because running scripts is prohibited on this system
Redis:字符串類型數據的操作命令
JS input number and standard digit number are compared. The problem of adding 0 to 0
Dynamic programming 01 knapsack and complete knapsack
Common network state detection and analysis tools
Qt学习18 登录对话框实例分析
Analysis of the characteristics of page owner
simpleParallax. JS (create poor visual effects for website pictures)