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

边栏推荐
- Golang — template
- JS input number and standard digit number are compared. The problem of adding 0 to 0
- FPGA test method takes mentor tool as an example
- JS first summary
- Example analysis of QT learning 18 login dialog box
- 战略、战术(和 OKR)
- Redis: commandes d'action pour les données de type chaîne
- Print. JS -- web page file printing
- QT learning 25 layout manager (4)
- Dynamic programming 01 knapsack and complete knapsack
猜你喜欢

全局事件总线

JS Part 2

GoLand 2021.2 configure go (go1.17.6)

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

Golang - command line tool Cobra

Article content typesetting and code highlighting

Conversion function and explicit
![[technology development-24]: characteristics of existing IOT communication technology](/img/f3/a219fe8e7438b8974d2226b4c3d4a4.png)
[technology development-24]: characteristics of existing IOT communication technology

Using registered classes to realize specific type matching function template

Qt学习21 Qt 中的标准对话框(下)
随机推荐
[技術發展-24]:現有物聯網通信技術特點
How to delete an attribute or method of an object
Message subscription and publishing
解决MySql 1045 Access denied for user ‘root‘@‘localhost‘ (using password: YES)
How to use lxml to judge whether the website announcement is updated
allegro,orcad, net alias,port,off-page connector之间的异同点和如何选取
Formation of mil-100 (FE) coated small molecule aspirin [email protected] (FE) | glycyrrhetinic acid modified metal organ
Uniapp skills - scrolling components -1
JS Part 2
Redis: redis data structure and key operation commands
Golang — template
Raft 协议
Go language web development series 25: Gin framework: using MD5 to verify the signature for the interface station
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
[bw16 application] instructions for firmware burning of Anxin Ke bw16 module and development board update
QT learning 21 standard dialog box in QT (Part 2)
Windos creates Cordova prompt because running scripts is prohibited on this system
MySQL 数据处理值增删改
[développement technologique - 24]: caractéristiques des technologies de communication Internet des objets existantes
JS shift operators (< <,> > and > > >)