用C/C++写一个时间计算器。
#include<iostream>
using namespace std;
struct time
{
int hour;
int minute;
};
int main()
{
struct time sum;
sum.hour = 0;
sum.minute = 0;
struct time time1;
while(1)
{
cout << "请输入小时数: ";
cin >> time1.hour;
cout << "请输入分钟数: ";
cin >> time1.minute;
sum.hour += time1.hour;
sum.minute += time1.minute;
if (sum.minute > 60)
{
sum.hour += 1;
sum.minute = (sum.minute - 60);
}
cout << sum.hour << "h " << sum.minute << "min" << endl;
}
return 0;
}