View Code of Problem 3310

#include<stdio.h>
int main(){
	int y,m,d,hh,mm,ss,k;
	scanf("%d",&k);
	while(k-->0){
		scanf("%d/%d/%d-%d:%d:%d",&y,&m,&d,&hh,&mm,&ss);
		printf("%02d/%02d/%d-",m,d,y);
		if(hh==12){
			printf("%02d:%02d:%02dpm\n",hh,mm,ss);
		}
		else if(hh==0){
			printf("%02d:%02d:%02dam\n",hh+12,mm,ss);
		}
		else if(hh>12){
			printf("%02d:%02d:%02dpm\n",hh-12,mm,ss);
		}
		else if(hh<12){
			printf("%02d:%02d:%02dam\n",hh,mm,ss);
		}
	}
	return 0;
}

Double click to view unformatted code.


Back to problem 3310