求解释
查看原帖
求解释
1281623
Problem1613end楼主2024/8/1 20:35

为何第十二行大于改小于才过?

#include<bits/stdc++.h>
using namespace std;
int n;
struct loct{
	string s;
	int y,d,m,xh;
}a[1010];
bool cmp(loct at,loct bt){
	if(at.y>bt.y)  return 0;
	else  if(at.y==bt.y && at.m>bt.m)  return 0;
	else  if(at.y==bt.y && at.m==bt.m && at.d>bt.d)  return 0;
	else  if(at.y==bt.y && at.m==bt.m && at.d==bt.d && at.xh>bt.xh)  return 0;//第十二行
	else  return 1;
}
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i].s>>a[i].y>>a[i].m>>a[i].d;
		a[i].xh=i;
	}
	stable_sort(a+1,a+n+1,cmp);
	for(int i=1;i<=n;i++){
		cout<<a[i].s<<endl;
	}
	return 0;
}
// 32 312 302
2024/8/1 20:35
加载中...