当前位置:网站首页>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;
}
边栏推荐
- Interface for querying IP home
- [acnoi2022] guess numbers
- allegro,orcad, net alias,port,off-page connector之间的异同点和如何选取
- JS general form submission 1-onsubmit
- Redis:字符串类型数据的操作命令
- Qt学习22 布局管理器(一)
- FPGA测试方法以Mentor工具为例
- [combinatorics] permutation and combination (examples of combinatorial number of multiple sets | three counting models | selection problem | combinatorial problem of multiple sets | nonnegative intege
- 1px problem of mobile terminal
- Uio-66-cooh loaded bendamostine | hydroxyapatite (HA) coated MIL-53 (FE) nanoparticles | baicalin loaded manganese based metal organic skeleton material
猜你喜欢
Dlopen() implements dynamic loading of third-party libraries
Example analysis of QT learning 18 login dialog box
TS code automatically generates JS
Go language unit test 5: go language uses go sqlmock and Gorm to do database query mock
Golang - command line tool Cobra
Go: send the get request and parse the return JSON (go1.16.4)
Interface for querying IP home
JS Part 2
jvm-对象生命周期
Mysql:insert date:sql error [1292] [22001]: data truncation: incorrect date value:
随机推荐
Global event bus
JVM class loading
JVM family - overview, program counter day1-1
[bw16 application] instructions for firmware burning of Anxin Ke bw16 module and development board update
Dynamic programming 01 knapsack and complete knapsack
UiO-66-COOH装载苯达莫司汀|羟基磷灰石( HA) 包裹MIL-53(Fe)纳米粒子|装载黄芩苷锰基金属有机骨架材料
[combinatorics] permutation and combination (examples of combinatorial number of multiple sets | three counting models | selection problem | combinatorial problem of multiple sets | nonnegative intege
Current situation, analysis and prediction of information and innovation industry
js . Find the first palindrome string in the array
Another industry has been broken by Chinese chips. No wonder the leading analog chip companies in the United States have cut prices and sold off
玖逸云黑免费无加密版本源码
可编程逻辑器件软件测试
JS new challenges
Use and design of Muduo buffer class
Go language unit test 4: go language uses gomonkey to test functions or methods
RocksDB LRUCache
【吉林大学】考研初试复试资料分享
Multi person collaborative data annotation based on Baidu brain easydata from scratch
Using registered classes to realize specific type matching function template
GoLand 2021.1: rename the go project