#include <iostream>
using namespace std;
class complex {
public:
complex() {shi=0;fen=0;miao=0;}
complex(int shi,int fen, int miao) {this->shi = shi;this->fen = fen; this->miao = miao;}
complex operator+ (complex &r)
{
complex rst;
rst.shi = this->shi + r.shi;
rst.fen = this->fen + r.fen;
rst.miao = this->miao + r.miao;
if(rst.miao>60)
{
rst.fen++;
rst.miao=rst.miao-60;
}
if(rst.fen>60)
{
rst.shi++;
rst.fen=rst.fen-60;
}
if(rst.shi>24)
{
rst.shi=rst.shi-24;
}
return rst;
}
complex operator- (complex &r)
{
complex rst;
rst.shi = this->shi - r.shi;
rst.fen = this->fen - r.fen;
rst.miao = this->miao - r.miao;
if(rst.miao<0)
{
rst.fen--;
rst.miao=rst.miao+60;
}
if(rst.fen<0)
{
rst.shi--;
rst.fen=rst.fen+60;
}
if(rst.shi<0)
{
cout<<"不够减"<<endl;
}
return rst;
}
void show() {cout<<shi<<":"<<fen<<":"<<miao<<endl;}
private:
int shi;
int fen;
int miao;
};
int main()
{
complex r2;
complex r0(8,5,58);
complex r1(6,56,3);
cout<<"加法"<<endl;
r2 = r0+r1;
r2.show();
cout<<"减法"<<endl;
r2 =r0-r1;
r2.show();
}