View Code of Problem 3310

#include<stdio.h>
int main(){
	int t,i;
	int yy,mm,dd,h,m,s;
	scanf("%d",&t);
	for(i=0;i<t;i++){
		scanf("%d/%d/%d-%d:%d:%d",&yy,&mm,&dd,&h,&m,&s);
		printf("%02d/%02d/%d-",mm,dd,yy);
		if(h>12){
			printf("%02d:%02d:%02dpm\n",h-12,m,s);
		}else if(h==12){
			printf("%02d:%02d:%02dpm\n",h,m,s);
		}else if(h==0){
			printf("12:%02d:%02dam\n",m,s);
		}else{
			printf("%02d:%02d:%02dam\n",h,m,s);
		}
	}
	return 0;
} 

Double click to view unformatted code.


Back to problem 3310