题目描述
输入三个字符串,按由小到大的顺序输出
输入
3行字符串
输出
按照从小到大输出成3行
样例输入
cde
afg
abc
样例输出
abc
afg
cde
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
int main ()
{
char a[1001],b[1001],
c[1001],d[1001];
gets(a);
gets(b);
gets(c);
if(strcmp(a, b) > 0)
{
strcpy(d, a);
strcpy(a, b);
strcpy(b, d);
}
if(strcmp(b, c) > 0)
{
strcpy(d, b);
strcpy(b,c);
strcpy(c, d);
}
if(strcmp(a, b) > 0)
{
strcpy(d, a);
strcpy(a, b);
strcpy(b, d);
}
printf("%s\n",a);
printf("%s\n",b);
printf("%s\n",c);
}