#include<conio.h>
#include<iostream.h>
#include<graphics.h>
class diem
{
private:
int x;
int y;
public:
void nhap()
{
cout<<"\nnhap hoanh do: ";
cin>>x;
cout<<"nhap tung do: ";
cin>>y;
}
void hien()
{
cout<<"gia tri diem: ("<<x<<";"<<y<<")";
}
void thaydoi();
void hoanhdo()
{
cout<<x;;
}
void tungdo()
{
cout<<y;
}
void tinhtienlen();
void tinhtienxuong();
void tinhtientrai();
void tinhtienphai();
void dohoa()
{
int m,n;
m=n=0;
initgraph(&m,&n,"");
}
};
void diem::thaydoi()
{
int a,b;
cout<<"\nnhap gia tri hoanh do moi: ";
cin>>a;
x=a;
cout<<"nhap gia tri tung do moi: ";
cin>>b;
y=b;
}
void diem::tinhtienlen()
{
int z;
cout<<"\ntinh tien len:";
cout<<"\nnhap gia tri: ";
cin>>z;
y=y+z;
}
void diem::tinhtienxuong()
{
int z;
cout<<"\ntinh tien xuong:";
cout<<"\nnhap gia tri: ";
cin>>z;
y=y-z;
}
void diem::tinhtientrai()
{
int z;
cout<<"\ntinh tien trai:";
cout<<"\nnhap gia tri: ";
cin>>z;
x=x-z;
}
void diem::tinhtienphai()
{
int z;
cout<<"\ntinh tien phai:";
cout<<"\nnhap gia tri: ";
cin>>z;
x=x+z;
}
int main()
{
//thuc hien cac thao tac nhap diem, hien diem, thay doi gia tri diem, tinh tien, ve diem bang do hoa...
}
luy y: cfree 4 ko dung duoc do hoa graphics. vi vay may nao dung cfree4 se chay chuong trinh ne voi viec ko dung thu vien graphics.h va ham dohoa(). con trong ham main() co the viet the nay (cai ne tuy moi nguoi nha, ko nhat thiet la giong nhau, ai ma ko biet lam nua thi...
):
#include<conio.h>
#include<iostream.h>
class diem
{
private:
int x;
int y;
public:
void nhap()
{
cout<<"\nnhap hoanh do: ";
cin>>x;
cout<<"nhap tung do: ";
cin>>y;
}
void hien()
{
cout<<"gia tri diem: ("<<x<<";"<<y<<")";
}
void thaydoi();
void hoanhdo()
{
cout<<x;;
}
void tungdo()
{
cout<<y;
}
void tinhtienlen();
void tinhtienxuong();
void tinhtientrai();
void tinhtienphai();
};
void diem::thaydoi()
{
int a,b;
cout<<"\nnhap gia tri hoanh do moi: ";
cin>>a;
x=a;
cout<<"nhap gia tri tung do moi: ";
cin>>b;
y=b;
}
void diem::tinhtienlen()
{
int z;
cout<<"\ntinh tien len:";
cout<<"\nnhap gia tri: ";
cin>>z;
y=y+z;
}
void diem::tinhtienxuong()
{
int z;
cout<<"\ntinh tien xuong:";
cout<<"\nnhap gia tri: ";
cin>>z;
y=y-z;
}
void diem::tinhtientrai()
{
int z;
cout<<"\ntinh tien trai:";
cout<<"\nnhap gia tri: ";
cin>>z;
x=x-z;
}
void diem::tinhtienphai()
{
int z;
cout<<"\ntinh tien phai:";
cout<<"\nnhap gia tri: ";
cin>>z;
x=x+z;
}
int main()
{
diem p;
p.nhap();
p.hien();
p.thaydoi();
p.hien();
p.tinhtienlen();
p.hien();
return 0;
}