poj 3751 时间日期格式转换

#include <iostream>        //水题
using namespace std; //12:00pm 表示正午,12:00am表示午夜
int main()
{
int t,y,mm,d,h,m,s,tag;char ch[2][3]={"am","pm"};
cin
>>t;
while(t--)
{
scanf(
"%d/%d/%d-%d:%d:%d",&y,&mm,&d,&h,&m,&s);
if(h<12)
tag
=0,h=(h==0)?12:h;
else
tag
=1,h=(h==12)?12:h-12;
printf(
"%02d/%02d/%04d-%02d:%02d:%02d%s\n",mm,d,y,h,m,s,ch[tag]);
}
return 0;
}

  

posted on 2011-07-22 16:53  sysu_mjc  阅读(106)  评论(0编辑  收藏  举报

导航