View Code of Problem 3310

#include <bits/stdc++.h>
using namespace std;
 
int main()
{
	int t;
	cin>>t;
	while(t--)
	{
		string s;
		stringstream s1;
		cin>>s;
		string y,m,d,h,f,ss;
		y=s.substr(0,4);
		m=s.substr(5,2);
		d=s.substr(8,2);
		h=s.substr(11,2);
		f=s.substr(14,2);
		ss=s.substr(17,2);
		s1<<h;
		int hour;
		s1>>hour;
//	cout<<hour+1<<endl;
if(hour==0)
{
	hour+=12;
	cout<<y<<"/"<<m<<"/"<<d<<"-";
	printf("%02d",hour);
	cout<<":"<<f<<":"<<ss<<"am"<<endl;
//	printf("%s/%s/%s-%02d:%s:%sam\n",y,m,d,f,ss);
}
else if(hour>12)
{
	hour-=12;
cout<<y<<"/"<<m<<"/"<<d<<"-";
	printf("%02d",hour);
	cout<<":"<<f<<":"<<ss<<"pm"<<endl;
}
else if(hour==12)
{
	cout<<y<<"/"<<m<<"/"<<d<<"-";
	printf("%02d",hour);
	cout<<":"<<f<<":"<<ss<<"pm"<<endl;
}
 
 
	
	}
	return 0;
 } 
/*
F:\temp\22494833.28363\Main.cc:2:25: error: bits/stdc++.h: No such file or directory
F:\temp\22494833.28363\Main.cc: In function 'int main()':
F:\temp\22494833.28363\Main.cc:8: error: 'cin' was not declared in this scope
F:\temp\22494833.28363\Main.cc:11: error: 'string' was not declared in this scope
F:\temp\22494833.28363\Main.cc:11: error: expected ';' before 's'
F:\temp\22494833.28363\Main.cc:12: error: 'stringstream' was not declared in this scope
F:\temp\22494833.28363\Main.cc:12: error: expected ';' before 's1'
F:\temp\22494833.28363\Main.cc:13: error: 's' was not declared in this scope
F:\temp\22494833.28363\Main.cc:14: error: expected ';' before 'y'
F:\temp\22494833.28363\Main.cc:15: error: 'y' was not declared in this scope
F:\temp\22494833.28363\Main.cc:16: error: 'm' was not declared in this scope
F:\temp\22494833.28363\Main.cc:17: error: 'd' was not declared in this scope
F:\temp\22494833.28363\Main.cc:18: error: 'h' was not declared in this scope
F:\temp\22494833.28363\Main.cc:19: error: 'f' was not declared in this scope
F:\temp\22494833.28363\Main.cc:20: error: 'ss' was not declared in this scope
F:\temp\22494833.28363\Main.cc:21: error: 's1' was not declared in this scope
F:\temp\22494833.28363\Main.cc:28: error: 'cout' was not declared in this scope
F:\temp\22494833.28363\Main.cc:29: error: 'printf' was not declared in this scope
F:\temp\22494833.28363\Main.cc:30: error: 'endl' was not declared in this scope
F:\temp\22494833.28363\Main.cc:36: error: 'cout' was not declared in this scope
F:\temp\22494833.28363\Main.cc:37: error: 'printf' was not declared in this scope
F:\temp\22494833.28363\Main.cc:38: error: 'endl' was not declared in this scope
F:\temp\22494833.28363\Main.cc:42: error: 'cout' was not declared in this scope
F:\temp\22494833.28363\Main.cc:43: error: 'printf' was not declared in this scope
F:\temp\22494833.28363\Main.cc:44: error: 'endl' was not declared in this scope
*/

Double click to view unformatted code.


Back to problem 3310