1177

Posted ilovetheworld

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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 ",r[j].month,r[j].day,r[j].year); } }

 








以上是关于1177的主要内容,如果未能解决你的问题,请参考以下文章

POJ 1177 Picture

题目1177:查找---------------字符串的函数问题

[POJ1177]Picture

poj1177 Picture

P1177 模板快速排序

[HIHO1177]顺子(暴力,枚举)