当前位置:网站首页>String sort
String sort
2022-07-03 14:15:00 【Study hard 867】
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
yellowCode :
#include <stdio.h>
#include <string.h>
int main(){
char a[5][80];
char b[1][80];
int i,j;
for(i=0;i<5;i++){
scanf("%s",a[i]);
}
for(i=0;i<5;i++){
strcpy(b[0],a[i]);
for(j=i+1;j<5;j++){
if(strcmp(b[0],a[j])>0){
strcpy(b[0],a[j]);
strcpy(a[j],a[i]);
strcpy(a[i],b[0]);
}
}
}
printf("After sorted:\n");
for(i=0;i<4;i++){
printf("%s\n",a[i]);
}
printf("%s",a[4]);
}边栏推荐
- Eight sorts
- 6-9 statistics of single digits (15 points)
- JS get DPI, PX to cm, cm to PX
- Message subscription and publishing
- Exercise 9-1 time conversion
- JVM runtime data area
- 战略、战术(和 OKR)
- JS shift operators (< <,> > and > > >)
- PCB中常用快捷键
- Thinking about the arrangement problem in the backtracking problem (leetcode questions 46 and 47)
猜你喜欢

Vite project commissioning

556. 下一个更大元素 III

Polestar美股上市:5.5万台交付如何支持得起超200亿美元估值

Metal organic framework MOFs loaded with non steroidal anti-inflammatory drugs | zif-8 wrapped Prussian blue loaded quercetin (preparation method)

Article content typesetting and code highlighting

剑指 Offer 28. 对称的二叉树

28:第三章:开发通行证服务:11:在配置文件中定义属性,然后在代码中去获取;

Concat and concat_ Ws() differences and groups_ Use of concat() and repeat() functions

Exercise 10-1 judge the three digits that meet the conditions

NFT新的契机,多媒体NFT聚合平台OKALEIDO即将上线
随机推荐
7-7 12-24 hour system
中国锂电池电解液行业市场专项调研报告(2022版)
[clean up the extraordinary image of Disk C]
Exercise 10-1 calculate the sum of 1 to n using recursive functions
6-9 statistics of single digits (15 points)
js 2023. String pair equal to the target string after connection
JVM垃圾回收机
7-9 find a small ball with a balance
剑指 Offer 28. 对称的二叉树
Raft 协议
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
Metal organic framework MOFs loaded with non steroidal anti-inflammatory drugs | zif-8 wrapped Prussian blue loaded quercetin (preparation method)
Eight sorts
Exercise 6-2 using functions to sum special A-string sequences
Exercise 10-2 recursive factorial sum
Concat and concat_ Ws() differences and groups_ Use of concat() and repeat() functions
7-20 print 99 formula table (format output)
JS input number and standard digit number are compared. The problem of adding 0 to 0
C language,%d% Difference between 2D%2d%02d
7-8 overspeed judgment