CODE[VS] 2780 ZZWYYQWZHZ

题目描述 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.

用sort数组快排能过两个点。

正解是字符串快排,

是个字符串快排的模板。

另:

为什么我找不到街舞里那个:

“我是个机器人摇摇摆摆。”。。

ac代码:

 1 #include<iostream>
 2 #include<cstdio>
 3 #include<algorithm>
 4 #include<cstring>
 5 #include<cmath>
 6 using namespace std;
 7 
 8 int n;
 9 string s[52];
10 
11 bool cmp(string x,string y)
12 {
13     int l1=x.size() ;
14     int l2=y.size() ;
15     if(l1<l2) return 1;
16     if(l1==l2&&x<y) return 1;
17     return 0;
18 }
19 
20 int main()
21 {
22     scanf("%d",&n);
23     for(int i=1;i<=n;++i)
24         cin>>s[i];
25     sort(s+1,s+n+1,cmp);
26     for(int i=1;i<=n;++i)
27         cout<<s[i]<<endl;
28     return 0;
29 }

如果你不开心,那我就把右边这个帅傻子分享给你吧,
你看,他这么好看,跟个zz一样看着你,你还伤心吗?
真的!这照片盯上他五秒钟就想笑了。
一切都会过去的。
时间时间会给你答案2333
原文地址:https://www.cnblogs.com/Mary-Sue/p/9191057.html