题解 | #小乐乐定闹钟#
小乐乐定闹钟
http://www.nowcoder.com/practice/0f7e422e12be4a7f9958ca2a82abc775
说实话兄弟们我也不知道咋过的。。。
#include<iostream>
using namespace std;
int main()
{
int hour; int minute, k;
char c;
int i = 0;
cin >> hour >> c >> minute >> k;
int hour2=hour;
if (k < 60)minute = k;
else
{
while (k > 60)
{
k -= 60;
i++;
}
minute += k;
}
hour += i;
int abs=hour%24;
int x =hour/24;
if(x!=0&&24*x<hour&&hour2>12&&abs<23)
{
abs++;
}
minute %=60;
printf("%02d%c%02d",abs, c, minute);
return 0;
}