#include<bits/stdc++.h>
using namespace std;
class Ttb2{
float a,b,c;
public:
Ttb2 (){
a=b=c=0;
}
Ttb2(float x,float y,float z){
a=x;
b=y;
c=z;
}
Ttb2 operator+(Ttb2 y);
Ttb2 operator-(Ttb2 y);
Ttb2 operator*();
friend ostream&operator<<(ostream&x,Ttb2 y);
};
Ttb2 Ttb2::operator+(Ttb2 y){
Ttb2 n;
n.a=a+y.a;
n.b=b+y.b;
n.c=c+y.c;
return n;
}
Ttb2 Ttb2::operator-(Ttb2 y){
Ttb2 n;
n.a=a-y.a;
n.b=b-y.b;
n.c=c-y.c;
return n;
}
Ttb2 Ttb2::operator*(){
Ttb2 n;
n.a=-a;
n.b=-b;
n.c=-c;
return n;
}
ostream&operator<<(ostream&x,Ttb2 y){
x<<y.a<<"X"<<char(253);
if(y.b>0)
x<<"+"<<y.b<<"X";
else
x<<"-"<<-y.b<<"X";
if(y.c>0)
x<<"+"<<y.c<<endl;
else
x<<"-"<<-y.c<<endl;
return x;
}
int main(){
Ttb2 a(2,4,6);
Ttb2 b(2,3,2);
a=*a;
b=*b;
Ttb2 c=a+b;
Ttb2 d=a-b;
cout<<"TT t1 khi da doi dau la: "<<a<<endl;
cout<<"TT t2 khi da doi dau la: "<<b<<endl;
cout<<"Tong 2 TT la: "<<c<<endl;
cout<<"Hieu 2 TT la: "<<d<<endl;
ofstream f("ttb2.txt");
f<<"TT t1 khi da doi dau la: "<<a<<endl;
f<<"TT t2 khi da doi dau la: "<<b<<endl;
f<<"Tong 2 TT la: "<<c<<endl;
f<<"Hieu 2 TT la: "<<d<<endl;
return 0;
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKY2xhc3MgVHRiMnsKCWZsb2F0IGEsYixjOwoJcHVibGljOgoJCVR0YjIgKCl7CgkJCWE9Yj1jPTA7CgkJfQoJCVR0YjIoZmxvYXQgeCxmbG9hdCB5LGZsb2F0IHopewoJCQlhPXg7CgkJCWI9eT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