1095: C语言程序设计教程(第三版)课后习题10.2(C语言)

题目描述
输入三个字符串,按由小到大的顺序输出
输入
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);
}



客官记得一键三连啊!


posted @ 2021-01-04 00:05  S1Lu  阅读(48)  评论(0)    收藏  举报