字符串排序
来源:互联网 发布:手机点歌台软件 编辑:程序博客网 时间:2024/05/16 13:03
字符串排序
Problem Description
输入3个字符串,按字典序从小到大进行排序。
Input
输入数据有一行,分别为3个字符串,用空格分隔,每个字符串长度不超过100。
Output
输出排序后的三个字符串,用空格分隔。
Example Input
abcd cdef bcde
Example Output
abcd bcde cdef
代码:
#include <stdio.h>#include <string.h>#define MAXN 1000+5int main(){ char s[3][MAXN], t[MAXN]; int i, j; for(i = 0; i < 3; i++) { scanf("%s", &s[i]); } for(i = 0; i < 2; i++) { for(j = i; j < 3; j++) { if(strcmp(s[i], s[j]) > 0) { strcpy(t, s[i]); strcpy(s[i], s[j]); strcpy(s[j], t); } } } for(i = 0; i < 2; i++) { printf("%s ", s[i]); } printf("%s", s[2]); return 0;}
阅读全文
0 0
- 字符串排序
- 字符串排序
- 字符串排序
- 字符串排序
- 字符串排序
- 字符串排序。
- 字符串排序
- 字符串排序
- 字符串排序
- 字符串排序
- 字符串排序
- 字符串排序
- 字符串排序
- 字符串排序
- 字符串排序
- 字符串排序
- 字符串排序
- 排序字符串
- eclipse 常用快捷键
- Spring Cloud(十)高可用的分布式配置中心 Spring Cloud Config 中使用 Refresh
- SpringMVC与Struts2区别与比较总结
- 你对百兆SFP光模块了解有多少?_千兆单模光模块_万兆金光模块
- linux下安装zookeeper
- 字符串排序
- Floyd-算法--任意两点间的最短路问题
- Leetcode 738. Monotone Increasing Digits(算法分析week16)
- scala map 映射方法
- Junit 4 Tutorials(Junit 4 教程)
- mvc设计模式和mvc框架的区别
- [Unity基础]导入贴图、模型等资源文件时自动设置参数
- 使用JDBC链接MYSQL数据库
- CodeForces 28 C.Bath Queue(概率DP+组合数学)