zoukankan      html  css  js  c++  java
  • 1044: C语言程序设计教程(第三版)课后习题10.2

    题目描述

    输入三个字符串,按由小到大的顺序输出

    输入

    3行字符串

    输出

    按照从小到大输出成3行

    样例输入

    cde
    afg
    abc
    

    样例输出

    abc
    afg
    cde



     1 #include <stdio.h>
     2 #include <string.h>
     3 int main(int argc, char const *argv[])
     4 {
     5     
     6     char s1[81], s2[81], s3[81], temp[81];    
     7     gets(s1);
     8     gets(s2);
     9     gets(s3);
    10     if(strcmp(s1, s2) > 0)
    11     {
    12         strcpy(temp, s1); strcpy(s1, s2); strcpy(s2, temp);
    13     }
    14 
    15     if(strcmp(s2, s3) > 0)
    16     {
    17         strcpy(temp, s2); strcpy(s2, s3); strcpy(s3, temp);
    18     }
    19 
    20     if(strcmp(s1, s2) > 0)
    21     {
    22         strcpy(temp, s1); strcpy(s1, s2); strcpy(s2, temp);
    23     }
    24 
    25     printf("%s
    ", s1);
    26     printf("%s
    ", s2);
    27     printf("%s
    ", s3);
    28     return 0;
    29 }
  • 相关阅读:
    mysql查询版本
    mysql导出bug备注
    linux查找文件
    linux 编译式安装nginx
    linux文件校验
    linux 编译式安装apache
    网络层
    数据链路层
    物理层
    servlet过滤器
  • 原文地址:https://www.cnblogs.com/hello-lijj/p/7872908.html
Copyright © 2011-2022 走看看