注意
输入的时间存在三位数的内容
同时需要处理分钟数是一位的情况,此时分钟数应该用前导0填充,输出两位。
而小时数是一位时,只能输出一位。
#include <iostream>
#include <cstdio>
using namespace std;
int main(){
string str;
cin>>str;
int elapse;
cin>>elapse;
int x, y;
if(str.size() == 4){
x = (str[0]-'0')*10+(str[1]-'0');
y = (str[2]-'0')*10+(str[3]-'0');
}else{
x = str[0]-'0';
y = (str[1]-'0')*10+(str[2]-'0');
}
x = x*60 + y + elapse;
printf("%d%02d", x/60, x - x/60*60);
return 0;
}