题目链接:http://poj.org/problem?id=3751
题目大意:按照要求的格式将输入的时间日期进行转化。
1 #include <iostream>
2 #include <cstdio>
3 using namespace std;
4 int main ()
5 {
6 int t;
7 cin>>t;
8 while (t--)
9 {
10 int y,m,d,xs,fz,ms;
11 char ch1,ch2,ch3,ch4,ch5;
12 //scanf("%d/%d/%d-%d:%d:%d",y,m,d,xs,fz,ms);
13 //printf ("%d/%d/%d-%d:%d:%d",m,d,y,xs,fz,ms);
14 scanf("%d%c%d%c%d%c%d%c%d%c%d",&y,&ch1,&m,&ch2,&d,&ch3,&xs,&ch4,&fz,&ch5,&ms);
15 char q,p;
16 if (xs>=12)
17 {
18 q='p';
19 p='m';
20 }
21 else
22 {
23 q='a';
24 p='m';
25 }
26 if (xs==0)
27 xs=12;
28 xs=(xs>12?xs-12:xs);
29 printf ("%02d/%02d/%04d-%02d:%02d:%02d%c%c
",m,d,y,xs,fz,ms,q,p);
30 }
31 return 0;
32 }