字符串排序
Time Limit: 1000MS
Memory Limit: 65536KB
Problem Description
输入3个字符串,按字典序从小到大进行排序。
Input
输入数据有一行,分别为3个字符串,用空格分隔,每个字符串长度不超过100。
Output
输出排序后的三个字符串,用空格分隔。
Example Input
abcd cdef bcde
Example Output
abcd bcde cdef#include<stdio.h> #include<string.h> int main() { char a[110],b[110],c[110],t[110],max[110],min[110]; scanf("%s%s%s",&a,&b,&c); strcpy(max,a),strcpy(min,a); if(strcmp(b,max)>0) strcpy(max,b); if(strcmp(c,max)>0) strcpy(max,c); if(strcmp(b,min)<0) strcpy(min,b); if(strcmp(c,min)<0) strcpy(min,c); if(strcmp(a,max)!=0&&strcmp(a,min)!=0) strcpy(t,a); else if(strcmp(b,max)!=0&&strcmp(b,min)!=0) strcpy(t,b); else if(strcmp(c,max)!=0&&strcmp(c,min)!=0) strcpy(t,c); printf("%s %s %s",min,t,max); getchar(); getchar(); return 0; }