#include
#include
using namespace std;
struct date
{
int year;
int month;
int day;
};
struct student
{
char name[50];
date birthday;
int score;
bool operator < (const student& s2) const
{
return score > s2.score;
}
};
int main()
{
student s[5];
int i;
for(i=0; i<5; i++)
{
printf("Please enter the name, birthday and score:\n");
scanf("%s %d %d %d %d", s[i].name, &s[i].birthday.year, &s[i].birthday.month, &s[i].birthday.day, &s[i].score);
}
sort(s, s+5);//排序函数,algorithm库里面的。
for(i=0; i<5; i++)
{
printf("name:%s, birthday:%d-%d-%d, score:%d\n", s[i].name, s[i].birthday.year, s[i].birthday.month, s[i].birthday.day, s[i].score);
}
return 0;
}