![]()
#include<bits/stdc++.h>
using namespace std;
class Time
{
private:
int minute;
int hour;
public:
void set(int h, int m)
{
minute = m;
hour = h;
}
friend int operator-(Time, Time);
};
int operator-(Time t2, Time t1)
{
return(t2.hour-t1.hour)*60+t2.minute-t1.minute;
}
int main()
{
int a, b, c, d;
Time t1, t2;
cin >> a >> b >> c >> d;
do{
t1.set(a,b);
t2.set(c,d);
cout <<(t2-t1)<<endl;
cin >> a>> b >> c >> d;
}while(!(a == 0 && b == 0 && c == 0 && d == 0));
}
![]()
![]()
#include<bits/stdc++.h>
using namespace std;
class CComplex
{
public:
CComplex(double r=0, double i=0):real(r), imag(i){};
CComplex operator+(const CComplex& c)
{
CComplex temp;
temp=*this;
temp.real += c.real;
temp.imag += c.imag;
return temp;
};
CComplex operator -=(const CComplex& c)
{
real-=c.real;
imag-=c.imag;
return *this;
};
friend CComplex operator-(const CComplex& c1, const CComplex& c2);
void Display() const;
private:
double real;
double imag;
};
CComplex operator-(const CComplex& c1, const CComplex& c2)
{
CComplex temp;
temp.real=c1.real-c2.real;
temp.imag=c1.imag-c2.imag;
return temp;
}
void CComplex::Display() const
{
cout <<"("<<real <<","<<" "<<imag<<")"<<endl;
}
int main()
{
double r,m;
cin>>r>>m;
CComplex c1(r,m);
cin >>r>>m;
CComplex c2(r,m);
CComplex c3=c1+c2;
c3.Display();
c3 = c1-c2;
c3.Display();
c3 -= c1;
c3.Display();
return 0;
}