1177

Problem Description 
 
对于输入的一些日期,日期格式为“MM/DD/YYYY”。编程将其按日期从小到大排列。(本问题只有一组测试数据,日期总数不超过100个)

当输入00/00/0000时,表示测试输入的结束(本行不处理)

Sample Input
12/31/2005
10/21/2003
02/12/2004
11/12/1999
10/22/2003
11/30/2005
00/00/0000
Sample Output
11/12/1999
10/21/2003
10/22/2003
02/12/2004
11/30/2005
12/31/2005



#include<algorithm> #include<cstdio> using namespace std; struct riqi { int day; int month; int year; }r[100]; int compare(riqi a,riqi b) { if(a.year==b.year) { if(a.month==b.month) { return a.day<b.day; } else { return a.month<b.month; } } else { return a.year<b.year; } } int main() { int i=0,j; while (scanf("%d/%d/%d",&r[i].month,&r[i].day,&r[i].year)!=EOF&&r[i].month!=00&&r[i].day!=00&&r[i].year!=0000) { i++; } sort(r,r+i,compare); for(j=0;j<i;j++) { printf("%02d/%02d/%d\n",r[j].month,r[j].day,r[j].year); } }

 

转载于:https://www.cnblogs.com/ilovetheworld/p/10139869.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值