简单的工作日期相加的小程序
#include <iostream>
struct date
{
public:
int hour;
int minite;
};
const int perhour = 60;
date sum(date a,date b)
{
date c;
c.minite = a.minite + b.minite;
c.hour = c.minite/60+a.hour + b.hour;
if (c.minite/60>0)
{
c.minite = c.minite%60;
}
return c;
}
void show(date a)
{
std::cout<<a.hour<<":"<<a.minite<<std::endl;
}
void main()
{
date a = {1,2};
date b = {2,59};
date c;
c = sum(a,b);
show(a);
show(b);
show(c);
system("pause");
}