View Code of Problem 3310

#include<iostream>
#include<string>
using namespace std;
int main(){
	int T;
	cin>>T;
	while(T--){
		int y,mo,d,h,m,c;
		string s;
		scanf("%4d/%2d/%2d-%2d:%2d:%2d",&y,&mo,&d,&h,&m,&c);
		if(h==0){
			h=h+12;
			s="am";
		}
		else if(h>0&&h<12){
			s="am";
		}
		else if(h==12){
			s="pm";
		}
		else if(h>12){
			h-=12;
			s="pm";
		}
		printf("%02d/%02d/%04d-%02d:%02d:%02d%s\n",mo,d,y,h,m,c,s.c_str());
	}
}

Double click to view unformatted code.


Back to problem 3310