题解 | #大整数排序#
大整数排序
https://www.nowcoder.com/practice/b744af632ac4499aa485d7bb048bb0aa
#include<iostream>
#include<queue>
#include<string>
using namespace std;
struct str{
string s;
int len;
str(string str,int l):s(str),len(l){}
bool operator<(const str& st)const{
if(len==st.len)
return s>st.s;
return len>st.len;
}
};
int main(){
int n;
while(cin>>n){
string s;
priority_queue<str> pq;
while(n--){
cin>>s;
pq.push(str(s,s.size()));
}
while(pq.size()){
cout<<pq.top().s<<endl;
pq.pop();
}
}
return 0;
}
科大讯飞公司氛围 455人发布
