View Code of Problem 3310

#include "stdio.h"
#include "string.h"

typedef struct Data{
	int y;
	int m;
	int d;
	int hh;
	int mm;
	int ss;
}Data;

int main(){
	int t;
	scanf("%d",&t);
	Data date;
	while(t--){
		scanf("%d/%02d/%02d-%02d:%02d:%02d",&date.y,&date.m,&date.d,&date.hh,&date.mm,&date.ss);
		if(date.hh>12&&date.hh<24)
			printf("%02d/%02d/%d-%02d:%02d:%02dpm\n",date.m,date.d,date.y,date.hh-12,date.mm,date.ss);
		else if(date.hh<12&&date.hh>=1)
			printf("%02d/%02d/%d-%02d:%02d:%02dam\n",date.m,date.d,date.y,date.hh,date.mm,date.ss);
		else if(date.hh==0)
			printf("%02d/%02d/%d-%02d:%02d:%02dam\n",date.m,date.d,date.y,date.hh+12,date.mm,date.ss);
		else if(date.hh==12)
			printf("%02d/%02d/%d-%02d:%02d:%02dpm\n",date.m,date.d,date.y,date.hh,date.mm,date.ss);
	}
}

Double click to view unformatted code.


Back to problem 3310