#include<stdio.h>
#include<string.h>
int swap(char *,char *);
int main()
{
char str1[20],str2[31],str3[20];
gets(str1);
gets(str2);
gets(str3);
if(strcmp(str1,str2)>0) swap(str1,str2);
if(strcmp(str1,str3)>0) swap(str1,str3);
if(strcmp(str2,str3)>0) swap(str2,str3);
printf("%s\n%s\n%s\n",str1,str2,str3);
}
int swap(char *p1,char *p2)
{
char p[40];
strcpy(p,p1);
strcpy(p1,p2);
strcpy(p2,p);
}
输入3个字符串,按由小到大的顺序排列。
最新推荐文章于 2024-04-16 17:11:25 发布