View Code of Problem 3310

#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
#define inf 0x7fffffff

int main() {
	int t;
	scanf("%d",&t);
	while(t--){
		int y,mo,d,h,mi,s;
		int flag;
		scanf("%d/%d/%d-%d:%d:%d",&y,&mo,&d,&h,&mi,&s);
		if(h>=12&&h<=23){
			flag=1;
		}else{
			flag=0;
		}
		if(flag==1){
			if(h==12){
				printf("%02d/%02d/%d-%02d:%02d:%02dpm\n",mo,d,y,h,mi,s);
			}else{
				printf("%02d/%02d/%d-%02d:%02d:%02dpm\n",mo,d,y,h-12,mi,s);
			}
		}else{
			if(h==0){
				printf("%02d/%02d/%d-%02d:%02d:%02dam\n",mo,d,y,h+12,mi,s);
			}else{
				printf("%02d/%02d/%d-%02d:%02d:%02dam\n",mo,d,y,h,mi,s);
			}
		}
	}
	return 0;
}

Double click to view unformatted code.


Back to problem 3310