View Code of Problem 3310

#include<iostream>
#include<cstdio>
using namespace std;
int main() {
	int T;
	cin>>T;
	while(T--) {
		int year,month,day,h,m,s;
		scanf("%d/%d/%d-%d:%d:%d",&year,&month,&day,&h,&m,&s);
		if(h<12) {
			if(h==0) printf("%02d/%02d/%d-%02d:%02d:%02dam\n",month,day,year,h+12,m,s);
			else printf("%02d/%02d/%d-%02d:%02d:%02dam\n",month,day,year,h,m,s);
		}else {
			if(h==12) printf("%02d/%02d/%d-%02d:%02d:%02dpm\n",month,day,year,h,m,s);
			else printf("%02d/%02d/%d-%02d:%02d:%02dpm\n",month,day,year,h-12,m,s);
		}
	}
} 

Double click to view unformatted code.


Back to problem 3310