1182: 按出生日期排序(结构体专题)

1182: 按出生日期排序(结构体专题)

Time Limit: 1 Sec   Memory Limit: 128 MB
Submit: 1409   Solved: 888

Submit Status Web Board

Description

送人玫瑰手有余香,小明希望自己能带给他人快乐,于是小明在每个好友生日的时候发去一份生日祝福。小明希望将自己的通讯录按好友的生日排序排序,这样就查看起来方便多了,也避免错过好友的生日。为了小明的美好愿望,你帮帮他吧。小明的好友信息包含姓名、出生日期。其中出生日期又包含年、月、日三部分信息。输入n个好友的信息,按生日的月份和日期升序输出所有好友信息。

Input

首先输入一个整数n(1<=n<=10),表示好友人数,然后输入n行,每行包含一个好友的信息:姓名(不超过8位),以及三个整数,分别表示出生日期的年月日。

Output

按过生日的先后(月份和日期)输出所有好友的姓名和出生日期,用空格隔开,出生日期的输出格式见输出样例。

Sample Input

3
Zhangling 1985 2 4
Wangliang 1985 12 11
Fangfang 1983  6 1

Sample Output

Zhangling 1985-02-04
Fangfang 1983-06-01
Wangliang 1985-12-11


代码:

#include
#include
#include
using namespace std;
struct node
{
	char name[10];
	int year,month,day;
}a[15];
int cmp(node x,node y)
{
	if(x.month!=y.month)
	   return x.month

你可能感兴趣的:(结构体排序,排序)