我代码轮着爆5、6
5号WA
#include<bits/stdc++.h>
using namespace std;
class people{
public:
string name;
int y,m,d;
};
bool operator<(people a,people b){
if(a.y != b.y){
return a.y < b.y;
}else if(a.m != b.m){
return a.m < b.m;
}else if(a.d != b.d){
return a.d < b.d;
}
return true;
}
int main(){
int n;
cin >> n;
vector<people> num;
for(int t = 0;t < n;t++){
people temp;
cin >> temp.name >> temp.y >> temp.m >> temp.d;
num.push_back(temp);
}
sort(num.begin(),num.end());
for(int t = 0;t < n;t++){
cout << num[t].name << endl;
}
return 0;
}
6号测试点WA
#include<bits/stdc++.h>
using namespace std;
class people{
public:
string name;
int y,m,d;
};
bool operator<(people a,people b){
if(a.y != b.y){
return a.y < b.y;
}else if(a.m != b.m){
return a.m < b.m;
}else if(a.d != b.d){
return a.d < b.d;
}
return false;
}
int main(){
int n;
cin >> n;
vector<people> num;
for(int t = 0;t < n;t++){
people temp;
cin >> temp.name >> temp.y >> temp.m >> temp.d;
num.push_back(temp);
}
sort(num.begin(),num.end());
for(int t = 0;t < n;t++){
cout << num[t].name << endl;
}
return 0;
}
不同之处:21、58行返回
求助但是不要给题解,指出错误即可,谢谢