文章

54

粉丝

0

获赞

12

访问

1.2k

头像
大整数排序 题解:
P1412 华中科技大学机试题
发布于2026年1月27日 21:26
阅读数 20

#include<iostream>
#include<algorithm>
using namespace std;

const int N=110;

int n;

bool cmp(string a,string b)
{
	if(a.size()!=b.size())
		return a.size()<b.size();
    return a<b;
}

int main()
{
	while(cin>>n)
	{
		string s[N];
		for(int i=0;i<n;i++)
			cin>>s[i];
		sort(s,s+n,cmp);
		for(int i=0;i<n;i++)
			cout<<s[i]<<endl;
	}
	return 0;
}

 

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发