Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
新手用C写的。。出来秀一下。。In Reply To:很短的AC代碼(相信可以去除struct令到更短) Posted by:miklcct at 2011-06-12 21:07:56 #include <stdio.h> #include <stdlib.h> int main() { int t,y,mon,d,h,min,s,i; scanf("%d",&t); for(i=0; i<t; i++) { scanf("%d/%d/%d-%d:%d:%d",&y,&mon,&d,&h,&min,&s); if(h>=0&&h<12) { if(h>=0&&h<1) h=h+12; printf("%02d/%02d/%04d-%02d:%02d:%02dam\n",mon,d,y,h,min,s); } else { if(h>=13) h=h-12; printf("%02d/%02d/%04d-%02d:%02d:%02dpm\n",mon,d,y,h,min,s); } } } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator