织梦源码网站模板,网站优化培训,wordpress directorypress,交互设计 网站推荐时间显示 - 蓝桥云课 (lanqiao.cn)
题目描述 题目分析
输入为毫秒#xff0c;故我们可以先将毫秒转化为秒#xff0c;由于只需要输出时分#xff0c;我们只需要将天数去除即可#xff0c;可以在这里多训练一次天数判断
#includebits/stdc.h
using namespace std…时间显示 - 蓝桥云课 (lanqiao.cn)
题目描述 题目分析
输入为毫秒故我们可以先将毫秒转化为秒由于只需要输出时分我们只需要将天数去除即可可以在这里多训练一次天数判断
#includebits/stdc.h
using namespace std;
int m[13] {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
bool is_ren(int n)
{if((n % 100 ! 0 n % 4 0) || n % 400 0)return true;return false;
}
int main()
{long long x; cin x;x / 1000;//一天有24 * 60 * 60 86400 秒 bool flag 0;for(int i 1970; ; i ){if(is_ren(i))m[2] 29;else m[2] 28;for(int j 1; j 12; j ){for(int k 1; k m[j]; k ){if(x 86400){k ;x - 86400; } else{flag 1;break;}}if(flag)break;}if(flag)break;}int a x / 3600;int b x % 3600 / 60;int c x % 60;printf(%02d:%02d:%02d, a, b, c);return 0;
} 但显然没必要可以这样
#includebits/stdc.h
using namespace std;
int main()
{long long x; cin x;x / 1000;//一天有24 * 60 * 60 86400 秒 while(x 86400)x - 86400;int a x / 3600;int b x % 3600 / 60;int c x % 60;printf(%02d:%02d:%02d, a, b, c);return 0;
}