• 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); } }

     

  • 相关阅读:
    ZOJ 3349 Special Subsequence
    ZOJ 3684 Destroy
    ZOJ 3820 Building Fire Stations
    HDU 5291 Candy Distribution
    HDU 3639 Hawk-and-Chicken
    HDU 4780 Candy Factory
    HDU 4276 The Ghost Blows Light
    ZOJ 3556 How Many Sets I
    技术人员的眼界问题
    神经网络和深度学习
  • 原文地址:https://www.cnblogs.com/ilovetheworld/p/10139869.html
Copyright © 2020-2023  润新知