#include<bits/stdc++.h>
using namespace std;
class tg{
int gio,phut,giay;
public:
tg(){
gio=phut=giay=0;
}
tg(int g,int p,int s){
gio=g;
phut=p;
giay=s;
}
int operator~(){
return (gio*60*60+phut*60+giay);
}
friend istream&operator>>(istream&x,tg &y);
friend ostream&operator<<(ostream&x,tg y);
};
istream&operator>>(istream&x,tg &y){
cout<<"gio:"; x>>y.gio;
cout<<"phut: " ; x>>y.phut;
cout<<"giay: "; x>>y.giay;
return x;
}
ostream&operator<<(ostream&x,tg y){
x<<y.gio<<" gio "<<y.phut<<" phut "<<y.giay<<" giay "<<endl;
return x;
}
int main(){
tg t1(4,2,5);
cout<<"thong tin cua t1:"<<endl;
cout<<t1<<endl;
tg t2;
cout<<"nhap thong tin cho t2: "<<endl;
cin>>t2;
int chenhlech=abs(~t1-~t2);
ofstream f("tg.txt");
cout<<"thong tin moc tgian 1 :"<<t1<<endl;
f<<"thong tin moc tgian 1 :"<<t1<<endl;
cout<<"thong tin moc tgian 2 :"<<t2<<endl;
f<<"thong tin moc tgian 2 :"<<t2<<endl;
cout<<"so giay chenh lech: "<<chenhlech<<endl;
f<<"so giay chenh lech: "<<chenhlech<<endl;
f.close();
return 0;
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKY2xhc3MgdGd7CglpbnQgZ2lvLHBodXQsZ2lheTsKCXB1YmxpYzoKCQl0ZygpewoJCQlnaW89cGh1dD1naWF5PTA7CgkJfQoJCXRnKGludCBnLGludCBwLGludCBzKXsKCQkJZ2lvPWc7CgkJCXBodXQ9cDsKCQkJZ2lheT1zOwoJCX0KCQlpbnQgb3BlcmF0b3J+KCl7CgkJCXJldHVybiAoZ2lvKjYwKjYwK3BodXQqNjArZ2lheSk7CgkgICAgfQoJICAgIGZyaWVuZCBpc3RyZWFtJm9wZXJhdG9yPj4oaXN0cmVhbSZ4LHRnICZ5KTsKCSAgICBmcmllbmQgb3N0cmVhbSZvcGVyYXRvcj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