#include<bits/stdc++.h>
#define ull unsigned long long
#define ll long long
using namespace std;
int T;
string s1, s2;
int x;
char ch;
void solve1() {
struct tm t;
t.tm_year = x;
scanf("%d-%d", &t.tm_mon, &t.tm_mday);
scanf("%d:%d:%d", &t.tm_hour, &t.tm_min, &t.tm_sec);
t.tm_year -= 1900; t.tm_mon -= 1;
printf("%d\n", mktime(&t));
}
void solve2() {
time_t xx = x;
struct tm *t;
t = localtime(&xx);
printf("%d-%02d-%02d %02d:%02d:%02d\n", t->tm_year + 1900, t->tm_mon + 1, t->tm_mday, t->tm_hour, t->tm_min, t->tm_sec);
}
int main() {
cin >> T; while(T--) {
cin >> x;
ch = getchar();
if(ch == '-') {
solve1();
}
else solve2();
}
return 0;
}
标签:02d,ch,转换,int,long,Unix,tm,时间,year
From: https://www.cnblogs.com/re0acm/p/17459840.html