View Code of Problem 3310

#include<iostream>
#include<cstdio>
#include<queue>
using namespace std;
int main() 
{	
	int t,n,y,r,s,f,m;
	cin>>t;
	while(t--)
	{
		scanf("%d/%d/%d-%d:%d:%d",&n,&y,&r,&s,&f,&m);
		if(s>=12)
		{
			if(s==24)
				printf("%02d/%02d/%02d-12:%02d:%02dam\n",y,r,n,f,m);
			else if(s==12)
				printf("%02d/%02d/%02d-%02d:%02d:%02dpm\n",y,r,n,s,f,m);
			else
				printf("%02d/%02d/%02d-%02d:%02d:%02dpm\n",y,r,n,s%12,f,m);
		}
		else
		{
			if(s==0)
				printf("%02d/%02d/%02d-12:%02d:%02dam\n",y,r,n,f,m);
			else
				printf("%02d/%02d/%02d-%02d:%02d:%02dam\n",y,r,n,s,f,m);
		}
	}
}

Double click to view unformatted code.


Back to problem 3310