zoukankan      html  css  js  c++  java
  • 字符串排序

    7-8 字符串排序(20 分)

    本题要求编写程序,读入5个字符串,按由小到大的顺序输出。

    输入格式:

    输入为由空格分隔的5个非空字符串,每个字符串不包括空格、制表符、换行符等空白字符,长度小于80。

    输出格式:

    按照以下格式输出排序后的结果:

    After sorted:
    每行一个字符串
    

    输入样例:

    red yellow blue green white
    

    输出样例:

    After sorted:
    blue
    green
    red
    white
    yellow
    #include<iostream>
    #include<algorithm>
    using namespace std;
    int main()
    {
        int a,b,c;
        string s[5];
        for(a=0;a<5;a++)
        {
            cin>>s[a];
        }
        sort(s,s+5);
        for(a=0;a<5;a++)
        {
            cout<<s[a]<<endl;
        }
        return 0;
     } 

    注释:C++的sort排序;

     
  • 相关阅读:
    k8s-istio记录
    k8s
    单词 -(动物)
    RxJs
    .netcore 3.1 unbuntu
    单词规整
    AutoMapper
    时间
    ye
    特殊权限
  • 原文地址:https://www.cnblogs.com/saber114567/p/8529196.html
Copyright © 2011-2022 走看看