时间相加
Description
用整数表示时间,如:1050表示10点50分,2010表示20点10分。现输入两个时间,求两个时间的和。
例:2030 + 850 = 520 不是2880
1055 + 850 = 1945 不是1905
Input
两行数据,每行一个整数。
Output
输出相加后的时间整数。
Sample Input
2030
850
Sample Output
520
时间相加
Description
用整数表示时间,如:1050表示10点50分,2010表示20点10分。现输入两个时间,求两个时间的和。
例:2030 + 850 = 520 不是2880
1055 + 850 = 1945 不是1905
Input
两行数据,每行一个整数。
Output
输出相加后的时间整数。
Sample Input
2030
850
Sample Output
520
#include <iostream>
using namespace std;
int main()
{
int a,b,h1,m1,h2,m2;
int t1,t2;
cin >> a;
cin >> b;
h1 = a/100;
m1 = a%100;
h2 = b/100;
m2 = b%100;
t1 = m1+m2;
t2 = h1+h2;
if(t1 >=60)
{
t1 -= 60;
t2 += 1;
}
t2 = t2%24;
cout << t2<<t1;
return 0;
}