View Code of Problem 3310

#include<iostream>
#include<string>
using namespace std;
int main() {
	int T; cin >> T;
	while (T--) {
		int n, y, r, h, m, s;
		char lj; string tv(""), tu("");
		cin >> n >> lj >> y >> lj >> r >> lj >> h >> lj >> m >> lj >> s;
		if (y < 10)tu = "0"; if (r < 10)tv = "0";
		cout << tu<<y << '/' << tv<<r << '/' << n << '-';
		string str("am");
		if (h >= 12)str = "pm";
		h %= 12;
		if (h > 0)cout << 0;
		else cout << 12;
		cout << ':';
		if (m < 10)cout << 0;
		cout << m;
		cout << ':';
		if (s < 10)cout << 0;
		cout << s;
		cout << str << endl;
	}
}

Double click to view unformatted code.


Back to problem 3310