View Code of Problem 3310

#include<stdio.h>
int main(){
	int t;
	scanf("%d",&t);
	int year,month,day,h,m,s;
	while(t--){
		scanf("%d/%d/%d-%d:%d:%d",&year,&month,&day,&h,&m,&s);
		int flag = 0;
		if(h >= 12){
			flag = 1;
			if(h>12) h = h%12;
		}
		if(h == 0) h=12;
		printf("%02d/%02d/%04d-%02d:%02d:%02d%s\n",month,day,year,h,m,s,flag ? "pm":"am");
	}
	return 0;
} 

Double click to view unformatted code.


Back to problem 3310