bai2-week3
// sp phu'c
#include
#include
#include
class SP
{
int pt,pa;
public:
void nhap();
void in();
SP nhan(SP);
void chia(SP);
SP cong(SP);
SP tru(SP);
float tinh();
};
void SP::nhap()
{
cout>pt;
cout>pa;
}
void SP::in()
{
cout
";
}
SP SP::nhan(SP a)
{ SP kq;
kq.pt=pt*a.pt;
kq.pa=pa*a.pa;
return(kq);
}
SP SP::cong(SP a)
{ SP kq;
kq.pt=pt+a.pt;
kq.pa=pa+a.pa;
return(kq);
}
SP SP::tru(SP a)
{ SP kq;
kq.pt=pt-a.pt;
kq.pa=pa-a.pa;
return(kq);
}
void SP::chia(SP a)
{ float x,y;
cout
";
}
float SP::tinh()
{ return(sqrt(pt*pt+pa*pa)); }
void main()
{
SP a,b;
a.nhap() ; cout
'; b.nhap();
a.cong(b).in();
a.tru(b).in();
a.nhan(b).in();
a.chia(b);
cout
'
getch();
}
Bạn đang đọc truyện trên: AzTruyen.Top