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

边栏推荐
- Go language web development series 30: gin: grouping by version for routing
- Global event bus
- QT learning 17 dialog box and its types
- js . Find the first palindrome string in the array
- Richview trvstyle liststyle list style (bullet number)
- Redis:字符串類型數據的操作命令
- allegro,orcad, net alias,port,off-page connector之间的异同点和如何选取
- TS code automatically generates JS
- Webpage connection database ~ simple implementation of addition, deletion, modification and query complete code
- Back to top implementation
猜你喜欢

Generate directories from web content

Implementation of Muduo accept connection, disconnection and sending data

Qt学习19 Qt 中的标准对话框(上)
[email protected]纳米粒子"/>金属有机骨架MIL-88负载阿霉素DOX|叶酸修饰UiO-66-NH2负载阿霉素[email protected]纳米粒子

GoLand 2021.1: rename the go project

Failure of vector insertion element iterator in STL

Dlopen() implements dynamic loading of third-party libraries

JVM系列——概述,程序计数器day1-1

Qt学习23 布局管理器(二)

JS Part 2
随机推荐
[ACNOI2022]猜数
How to promote the progress of project collaboration | community essay solicitation
Qt学习23 布局管理器(二)
MySQL 数据处理值增删改
Interface for querying IP home
JS continues to explore...
Go language web development series 28: solve cross domain access of CORS with gin contrib / CORS
Vite project commissioning
Qt学习21 Qt 中的标准对话框(下)
Go: send the get request and parse the return JSON (go1.16.4)
Go 1.16.4: purpose of go mod tidy
Depth and breadth first traversal of tree (regardless of binary tree)
Redis:字符串類型數據的操作命令
JVM family - overview, program counter day1-1
Uniapp skills - scrolling components -1
Cross linked cyclodextrin metal organic framework loaded methotrexate slow-release particles | metal organic porous material uio-66 loaded with flavonoid glycosides | Qiyue
使用vscode查看Hex或UTF-8编码
QT learning 25 layout manager (4)
金属有机骨架MIL-88负载阿霉素DOX|叶酸修饰UiO-66-NH2负载阿霉素[email protected]纳米粒子
3D vision - 2 Introduction to pose estimation - openpose includes installation, compilation and use (single frame, real-time video)