文章
79
粉丝
221
获赞
46
访问
202.1k
#include <iostream>
#include <string>
using namespace std;
int main() {
int n;
cin >> n;
string* s = new string[n];
for (int i = 0; i < n; i++) {
cin >> s[i];
int h = 0, m = 0, sth = 13, stm = 15;
for (int j = 0, flag = 0; j < s[i].size(); j++) {
if (s[i][j] == ':') {
flag = 1;
continue;
}
if (flag == 0)
h = h * 10 + s[i][j] - '0';
else
m = m * 10 + s[i][j] - '0';
}
cout << ((stm + m) / 60 + h + sth) % 24 << ':' << (stm + m) % 60 << endl;
}
return 0;
}
输入n个时分,提取出时h与分m,设置起始时分为sth:stm,则经过该时分后的时为((stm + m) / 60 + h + sth) % 24,分为(stm + m) % 60
登录后发布评论
暂无评论,来抢沙发