codevs 2780 ZZWYYQWZHZ

2780 ZZWYYQWZHZ

 

 时间限制: 1 s
 空间限制: 32000 KB
 题目等级: 青铜 Bronze
 
 
 
题目描述 Description

   可爱的小管在玩吹泡泡。忽然,他想到了一种排序。。。。。。。

输入描述 Input Description

第一行输入n,表示有n个数。(n>=20)

以下n行输入n个数,表示要排序的数(数字长度不超过200)。

输出描述 Output Description

有n行,即这些数从小到大的排序。

样例输入 Sample Input

5

1

2

3

4

5

样例输出 Sample Output

1

2

3

4

5

数据范围及提示 Data Size & Hint

n<=50

每个数字长度不超过200.

分类标签 Tags 

字符串处理 排序
 
 
/*
codevs 崩了,我也不知道代码对不对,应该是对的吧233333
*/
#include<iostream>
#include<algorithm>
using namespace std;
int n;
string s[30];
bool cmp(string s1,string s2)
{
    int l1=s1.size(),l2=s2.size();
    if(l1<l2)return 1;
    if(l1==l2&&s1<s2)return 1;
    return 0;
}
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)cin>>s[i];
    sort(s+1,s+n+1,cmp);
    for(int i=1;i<=n;i++)cout<<s[i]<<endl;
    return 0;
}

 

posted @ 2017-05-21 08:21  笑面  阅读(192)  评论(0编辑  收藏  举报