#题目思路
本题重点在于如何判断此时是否在高峰期内。 可以考虑将小时转化成分钟,每十分钟判断一次,如果处于高峰期,计时便增加二十分钟,否则增加十分钟,这样就可以记录所用时间且保持时间正常流逝。
#include <bits/stdc++.h>
using namespace std;
string s;
int h,m,t=120;
int main() {
cin>>s;
h=(s[1]-'0')+10*(s[0]-'0');
m=(s[4]-'0')+10*(s[3]-'0');
int time=h*60+m;
while (t!=0) {
if(time>=420&&time<600||time>=900&&time<1140){
time+=20;
}else{
time+=10;
}
t-=10;
}
h=time/60;
if(h>=24){
h%=24;
}
m=time%60;
if(h<10){
cout<<0<<h<<':';
if(m<10) cout<<0;
cout<<m;
}else{
cout<<h<<':';
if(m<10) cout<<0;
cout<<m;
}
return 0;
}