当前位置:网站首页>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]);
}边栏推荐
- QT learning 23 layout manager (II)
- Reflection -- basic usage
- 关于回溯问题中的排列问题的思考(LeetCode46题与47题)
- 7-9 find a small ball with a balance
- FPGA test method takes mentor tool as an example
- QT learning 21 standard dialog box in QT (Part 2)
- 7-11 calculation of residential water charges by sections
- Exercise 8-7 string sorting
- fpga阻塞赋值和非阻塞赋值
- 中国PETG市场预测及战略研究报告(2022版)
猜你喜欢
![[Jilin University] information sharing of postgraduate entrance examination and re examination](/img/1d/550a991385b842a21e2b301725407e.png)
[Jilin University] information sharing of postgraduate entrance examination and re examination

jvm-运行时数据区

7-8 overspeed judgment

Leetcode (4) -- find the median of two positively ordered arrays

牛客网:过河卒

concat和concat_ws()区别及group_concat()和repeat()函数的使用

好看、好用、强大的手写笔记软件综合评测:Notability、GoodNotes、MarginNote、随手写、Notes Writers、CollaNote、CollaNote、Prodrafts、Noteshelf、FlowUs、OneNote、苹果备忘录

使用并行可微模拟加速策略学习

Cross linked cyclodextrin metal organic framework loaded methotrexate slow-release particles | metal organic porous material uio-66 loaded with flavonoid glycosides | Qiyue

Exercise 10-1 calculate the sum of 1 to n using recursive functions
随机推荐
jvm-类加载
C language,%d% Difference between 2D%2d%02d
[Jilin University] information sharing of postgraduate entrance examination and re examination
Back to top implementation
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
C library function - qsort()
Example analysis of QT learning 18 login dialog box
1px problem of mobile terminal
etcd集群权限管理和账号密码使用
Simulated access
Exercise 6-6 use a function to output an integer in reverse order
LNMP环境mail函数不能发送邮件解决
Mysql多表查询 #子查询
Collection of mobile adaptation related articles
Eight sorts
Jiuyi cloud black free encryption free version source code
How to bold text in AI
npm install卡住与node-npy的各种奇怪报错
FPGA测试方法以Mentor工具为例
Exercise 10-2 recursive factorial sum