文章
49
粉丝
90
获赞
9
访问
26.7k
#include <iomanip>
#include <iostream>
#include<string>
using namespace std;
int m[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 };
void print(int x[5])
{
string s[5];
for (int i = 0; i < 5; i++)
{
if (x[i] < 10)
{
s[i] = "0";
}
s[i] += to_string(x[i]);
}
cout << "2009-" << s[0] << "-" << s[1] << " " << s[2] << ":" << s[3] << ":" << s[4] << endl;
}
int main()
{
auto n = 31535999;
while (cin >> n)
{
int x[5];
x[4] = n % 60;
x[3] = (n % 3600) / 60;
x[2] = (n % (3600 * 24)) / 3600;
int day = n / (3600 * 24) + 1;
int month = 1;
for (int i = 0; i < 12; i++)
{
if (day > m[i])
{
day -= m[i];
month++;
}
}
x[1] = day;
x[0] = month;
print(x);
}
return 0;
}
登录后发布评论
暂无评论,来抢沙发