模拟
2024-06-12 13:36:06
发布于:广东
12阅读
0回复
0点赞
#include <iostream>
#include <cstdio>
using namespace std;
int ct = 0;
int h1, h2, m1, m2, s1, s2;
int main(){
//freopen("test.in", "r", stdin);
//freopen("test.out", "w", stdout);
scanf("%d:%d:%d", &h1, &m1, &s1);
scanf("%d:%d:%d", &h2, &m2, &s2);
int h3 = h1, m3 = m1, s3 = s1;
if(s1 >= 60){
s1 -= 60;
m1 ++;
}if(m1 >= 60){
m1 -= 60;
h1 ++;
}if(h1 >= 24){
h1 -= 24;
}
while(h1 != h2 || m1 != m2 || s1 != s2){
if(!(s3 == 0 && m3 == 0 && h3 == 0))
if(s1 == 0 && m1 == 0 && h1 == 0){//特判
printf("next day\n");
}
printf("%02d:%02d:%02d\n", h1, m1, s1);
s1++;
if(s1 >= 60){
s1 -= 60;
m1 ++;
}if(m1 >= 60){
m1 -= 60;
h1 ++;
}if(h1 >= 24){
h1 -= 24;
}
ct++;
}
if(!(s3 == 0 && m3 == 0 && h3 == 0))
if(h2 == 0 && m2 == 0 && s2 == 0)
if(s1 == 0 && m1 == 0 && h1 == 0){
printf("next day\n");
}
printf("%02d:%02d:%02d\n", h1, m1, s1);
s1++;
printf("total=%d", ct);
//fclose(stdin);
//fclose(stdout);
return 0;
}
这里空空如也
有帮助,赞一个