求助,最后两个点无缘无故错了,请各位dalao们帮帮吧!!!
  • 板块P1104 生日
  • 楼主wweiyuzhao
  • 当前回复5
  • 已保存回复5
  • 发布时间2021/7/19 12:52
  • 上次更新2023/11/4 14:11:39
查看原帖
求助,最后两个点无缘无故错了,请各位dalao们帮帮吧!!!
137627
wweiyuzhao楼主2021/7/19 12:52

P1104

#include<iostream>
#include<algorithm>
using namespace std;
struct student{
	int yeah,month,day,num;
	string s;
}stu[110];
bool cmp(student a,student b)
{
	if(a.yeah<b.yeah)
	{
		return 1;
	}
	if(a.yeah>b.yeah)
	{
		return 0;
	}
	if(a.yeah==b.yeah)
	{
		if(a.month<b.month)
		{
			return 1;
		}
		if(a.month>b.month)
		{
			return 0;
		}
		if(a.month==b.month)
		{
			if(a.day<b.day)
			{
				return 1;
			}
			if(a.day>b.day)
			{
				return 0;
			}
			if(a.day==b.day)
			{
				if(a.num<b.num)
				{
					return 1;
				}
				else
				{
					return 0;
				}
			}
		}
	}
}
int main()
{
	int a;
	cin>>a;
	for(int i=1;i<=a;i++)
	{
		cin>>stu[i].s>>stu[i].yeah>>stu[i].month>>stu[i].day;
		stu[i].num=i;
	}
	stable_sort(stu+1,stu+a+1,cmp);
	for(int i=1;i<=a;i++)
	{
		cout<<stu[i].s<<endl;
	}
	return 0;
} 

后两点wa了,也不知道有什么地方错了,请各位dalao纠正

2021/7/19 12:52
加载中...