View Code of Problem 3310

#include<stdio.h>
struct time{
	int year;
	int month;
	int day;
	int h;
	int m;
	int s;
};
int main(){
	int t;
	struct time a;
	scanf("%d",&t);
	while(t--){
       		scanf("%d/%d/%d-%d:%d:%d",&a.year,&a.month,&a.day,&a.h,&a.m,&a.s);
       		printf("%02d/%02d/%d-",a.month,a.day,a.year);
       		if(a.h>12){
       		a.h=a.h-12;
       	    printf("%02d:%02d:%02dpm\n",a.h,a.m,a.s);
		   }
		   else if(a.h==12)
		   {
		   	printf("%02d:%02d:%02dpm\n",a.h,a.m,a.s);
		   }
		   else if(a.h<12&&a.h>0){
		   	printf("%02d:%02d:%02dam\n",a.h,a.m,a.s);
		   }
		   else
		   printf("12:%02d:%02dam\n",a.m,a.s);
	}
} 

Double click to view unformatted code.


Back to problem 3310