文章

64

粉丝

53

获赞

3

访问

14.8k

头像
国名排序 题解:
P1217 同济大学机试题
发布于2024年3月17日 20:52
阅读数 171

1217解题思路:sort()YYDS

#include <bits/stdc++.h>
using namespace std;
struct Student{
	string name;
}stu[105];
bool alph_ASC(Student a,Student b)
{
	return a.name<b.name;
}
int main()
{
	int n;
	while(cin>>n)
	{
		for(int i=0;i<n;i++)
		{
			cin>>stu[i].name;
		}
		stable_sort(stu,stu+n,alph_ASC);
		for(int i=0;i<n;i++)
		{
			cout<<stu[i].name<<endl;
		}
	}
}

 

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发