AcWing 3608. 大整数排序
原题链接
简单
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int,int>;
const int N = 1e6+10;
int t,n,m,k,l,r,op,x,y;
int f[N];
bool flag;
bool cmp(const string&s1,const string&s2){
int siz1 = s1.size();
int siz2 = s2.size();
if(siz1==siz2){
return s1<s2;
}else{
return siz1<siz2;
}
}
string strList[110];
void solve(){
cin>>n;
for(int i = 1;i<=n;i++){
cin>>strList[i];
}
sort(strList+1,strList+1+n,cmp);
for(int i = 1;i<=n;i++){
cout<<strList[i]<<"\n";
}
}
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
solve();
return 0;
}