当前位置:网站首页>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]);
}边栏推荐
- JS shift operators (< <,> > and > > >)
- 小项目(servelt+jsp+mysql+EL+JSTL)完成一个登录功能的Servlet,具有增删改查的操作。实现登录身份验证,防止非法登录,防止多点登录,记住用户名密码功能。
- JVM garbage collector
- Exercise 10-3 recursive implementation of exponential functions
- Current situation, analysis and prediction of information and innovation industry
- [clean up the extraordinary image of Disk C]
- jvm-运行时数据区
- allegro,orcad, net alias,port,off-page connector之间的异同点和如何选取
- Toast UI editor (editor allows you to edit your markup document using text or WYSIWYG, with syntax highlighting, scrolling synchronization, real-time preview and chart functions.)
- C language,%d% Difference between 2D%2d%02d
猜你喜欢

JS matrix zero

Example analysis of QT learning 18 login dialog box

Configure stylelint

天图投资冲刺港股:资产管理规模249亿 投了小红书与奈雪

7-8 overspeed judgment
[email protected] (FE) | glycyrrhetinic acid modified metal organ"/>Formation of mil-100 (FE) coated small molecule aspirin [email protected] (FE) | glycyrrhetinic acid modified metal organ

JVM object lifecycle

Leetcode(4)——尋找兩個正序數組的中比特數

修改数据库中的记录为什么报这个错

7-11 calculation of residential water charges by sections
随机推荐
剑指 Offer 28. 对称的二叉树
Collection of mobile adaptation related articles
Exercise 8-8 moving letters
Solve the problem of dormitory router campus network sharing login
6-9 statistics of single digits (15 points)
jvm-类加载
Facebook 如何将 Instagram 从 AWS 搬到自己的服务器
Redis: redis data structure and key operation commands
SSH访问控制,多次失败登录即封掉IP,防止暴力破解
Thinking about the arrangement problem in the backtracking problem (leetcode questions 46 and 47)
Exercise 6-1 classify and count the number of characters
JS first summary
QT learning 25 layout manager (4)
How to bold text in AI
Metal organic framework (MOFs) antitumor drug carrier | pcn-223 loaded with metronidazole | uio-66 loaded with ciprofloxacin hydrochloride(
7-16 find the set of integers that meet the given conditions
Nucleic acid modified metal organic framework drug carrier | pcn-223 metal organic framework encapsulated ad adamantane | zif-8 encapsulated adriamycin (DOX)
一文了解微分段应用场景与实现机制
QT learning 21 standard dialog box in QT (Part 2)
QT learning 17 dialog box and its types