User: 12520107
Infraction: Tạo thread thiếu chất lượng
Points: 1
Administrative Note:
Message to User:
Original Post:
Code của e mới viết nhưng không hiểu chỗ báo lỗi!! mong các anh chị giúp dùm e nhé
E xin chân thành cám ơn
Hậu tạ thì chưa biết ![Smile](https://forum.uit.edu.vn/core/images/smilies/smile.png)
![Frown](https://forum.uit.edu.vn/core/images/smilies/frown.png)
![Smile](https://forum.uit.edu.vn/core/images/smilies/smile.png)
![Smile](https://forum.uit.edu.vn/core/images/smilies/smile.png)
#include <stdio.h>
#include <conio.h>
#include <iostream>
using namespace std;
class CDonThuc
{
private:
int Bac;
float HeSo;
public:
CDonThuc();
CDonThuc(int Bac1, float HeSo1);
int GiaTri(int x);
void Nhap(int Bac1,float HeSo1);
CDonThuc operator+(CDonThuc &D2);
CDonThuc operator-(CDonThuc &D2);
float geta()
{
return HeSo;
}
int getn()
{
return Bac;
}
void Xuat()
{
if(Bac == 0)
cout<<HeSo;
else if (Bac == 1)
cout <<HeSo<<"*"<<"X";
if(HeSo==0)
cout <<"";
else if (HeSo == 1)
cout<<"X";
if(Bac!=0 && HeSo!=0 && Bac!=1 && HeSo !=1)
cout<<HeSo<<"*"<<"X^"<<Bac;
}
CDonThuc operator = (CDonThuc &D2);
};
//Cac Ham Thanh Phan Lop Don Thuc
void CDonThuc::Nhap(int Bac1,float HeSo1)
{
Bac = Bac1;
HeSo = HeSo1;
}
CDonThuc::CDonThuc()
{
Bac = 0;
HeSo = 0;
}
CDonThuc::CDonThuc(int Bac1, float HeSo1)
{
Bac = Bac1;
HeSo = HeSo1;
}
int CDonThuc::GiaTri(int x)
{
return int(HeSo*pow(x,Bac));
}
CDonThuc CDonThuc:
perator+(CDonThuc &D2)
{
CDonThuc D3;
D3.HeSo=HeSo+D2.HeSo;
D3.Bac = D2.Bac;
return D3;
}
CDonThuc CDonThuc:
perator-(CDonThuc &D2)
{
CDonThuc D3;
D3.HeSo=HeSo-D2.HeSo;
D3.Bac = D2.Bac;
return D3;
}
CDonThuc CDonThuc:
perator=(CDonThuc &D2)
{
Bac=D2.Bac;
HeSo=D2.HeSo;
}
class CDaThuc
{
private:
int BacDT;
CDonThuc A[100];
public:
void Nhap();
void Xuat();
int GiaTri(int x);
CDaThuc operator + (CDaThuc &D2);
CDaThuc operator - (CDaThuc &D2);
};
//Cac Ham Thanh Phan Cua Lop CDaThuc
void CDaThuc::Nhap()
{
int HeSo2;
cout<<"\nNhap Bac Cua Da Thuc: "<<endl;
cin>>BacDT;
for(int i = BacDT;i>=0;i--)
{
if(A[i].geta() > 0&& i!=BacDT) cout <<"+";
else
if (A[i].geta !=0 ) cout <<"";
A[i].Xuat();
}
}
int CDaThuc::GiaTri(int x)
{
int t=0;
for(int i=0;i<=BacDT;i++)
{
t=t+A[i].GiaTri(x);
}
return t;
}
CDaThuc CDaThuc:
perator+(CDaThuc &D2)
{
CDaThuc D3;
if(BacDT>D3.BacDT)
{
for(int i = 0;i<D2.BacDT;i++)
{
D3.A[i]=A[i]+D2.A[i];
}
for (int i=D2.BacDT+1;i<=BacDT;i++)
{
D3.A[i]=A[i];
D3.BacDT=BacDT;
}
}
else
{
for(int i=0;i<=BacDT;i++)
{
D3.A[i]=A[i]+D2.A[i];
}
for (int i=BacDT+1;i<D2.BacDT;i++)
{
D3.A[i]=D2.A[i];
D3.BacDT=D2.BacDT;
}
}
return D3;
}
CDaThuc CDaThuc:
perator-(CDaThuc &D2)
{
CDaThuc D3;
if(BacDT>=D2.BacDT)
{
for(int i=0;i<=D2.BacDT;i++)
{
D3.A[i]=A[i]-D2.A[i];
}
for(int i=D2.BacDT+1;i<=BacDT;i++)
D3.A[i]=A[i];
D3.BacDT=BacDT;
}
else
{
for(int i=0;i<=BacDT;i++)
{
D3.A[i]=A[i]-D2.A[i];
}
for(int i=BacDT+1;i<=D2.BacDT;i++)
D3.A[i]=D2.A[i] ;
D3.BacDT=D2.BacDT;
}
return D3;
}
void main()
{
CDaThuc A,B,C;
A.Nhap();
A.Xuat();
B.Nhap();
B.Xuat();
C=A+B;
C.Xuat();
getch();
}
#include <conio.h>
#include <iostream>
using namespace std;
class CDonThuc
{
private:
int Bac;
float HeSo;
public:
CDonThuc();
CDonThuc(int Bac1, float HeSo1);
int GiaTri(int x);
void Nhap(int Bac1,float HeSo1);
CDonThuc operator+(CDonThuc &D2);
CDonThuc operator-(CDonThuc &D2);
float geta()
{
return HeSo;
}
int getn()
{
return Bac;
}
void Xuat()
{
if(Bac == 0)
cout<<HeSo;
else if (Bac == 1)
cout <<HeSo<<"*"<<"X";
if(HeSo==0)
cout <<"";
else if (HeSo == 1)
cout<<"X";
if(Bac!=0 && HeSo!=0 && Bac!=1 && HeSo !=1)
cout<<HeSo<<"*"<<"X^"<<Bac;
}
CDonThuc operator = (CDonThuc &D2);
};
//Cac Ham Thanh Phan Lop Don Thuc
void CDonThuc::Nhap(int Bac1,float HeSo1)
{
Bac = Bac1;
HeSo = HeSo1;
}
CDonThuc::CDonThuc()
{
Bac = 0;
HeSo = 0;
}
CDonThuc::CDonThuc(int Bac1, float HeSo1)
{
Bac = Bac1;
HeSo = HeSo1;
}
int CDonThuc::GiaTri(int x)
{
return int(HeSo*pow(x,Bac));
}
CDonThuc CDonThuc:
![Embarrassment](https://forum.uit.edu.vn/core/images/smilies/redface.png)
{
CDonThuc D3;
D3.HeSo=HeSo+D2.HeSo;
D3.Bac = D2.Bac;
return D3;
}
CDonThuc CDonThuc:
![Embarrassment](https://forum.uit.edu.vn/core/images/smilies/redface.png)
{
CDonThuc D3;
D3.HeSo=HeSo-D2.HeSo;
D3.Bac = D2.Bac;
return D3;
}
CDonThuc CDonThuc:
![Embarrassment](https://forum.uit.edu.vn/core/images/smilies/redface.png)
{
Bac=D2.Bac;
HeSo=D2.HeSo;
}
class CDaThuc
{
private:
int BacDT;
CDonThuc A[100];
public:
void Nhap();
void Xuat();
int GiaTri(int x);
CDaThuc operator + (CDaThuc &D2);
CDaThuc operator - (CDaThuc &D2);
};
//Cac Ham Thanh Phan Cua Lop CDaThuc
void CDaThuc::Nhap()
{
int HeSo2;
cout<<"\nNhap Bac Cua Da Thuc: "<<endl;
cin>>BacDT;
for(int i = BacDT;i>=0;i--)
{
if(A[i].geta() > 0&& i!=BacDT) cout <<"+";
else
if (A[i].geta !=0 ) cout <<"";
A[i].Xuat();
}
}
int CDaThuc::GiaTri(int x)
{
int t=0;
for(int i=0;i<=BacDT;i++)
{
t=t+A[i].GiaTri(x);
}
return t;
}
CDaThuc CDaThuc:
![Embarrassment](https://forum.uit.edu.vn/core/images/smilies/redface.png)
{
CDaThuc D3;
if(BacDT>D3.BacDT)
{
for(int i = 0;i<D2.BacDT;i++)
{
D3.A[i]=A[i]+D2.A[i];
}
for (int i=D2.BacDT+1;i<=BacDT;i++)
{
D3.A[i]=A[i];
D3.BacDT=BacDT;
}
}
else
{
for(int i=0;i<=BacDT;i++)
{
D3.A[i]=A[i]+D2.A[i];
}
for (int i=BacDT+1;i<D2.BacDT;i++)
{
D3.A[i]=D2.A[i];
D3.BacDT=D2.BacDT;
}
}
return D3;
}
CDaThuc CDaThuc:
![Embarrassment](https://forum.uit.edu.vn/core/images/smilies/redface.png)
{
CDaThuc D3;
if(BacDT>=D2.BacDT)
{
for(int i=0;i<=D2.BacDT;i++)
{
D3.A[i]=A[i]-D2.A[i];
}
for(int i=D2.BacDT+1;i<=BacDT;i++)
D3.A[i]=A[i];
D3.BacDT=BacDT;
}
else
{
for(int i=0;i<=BacDT;i++)
{
D3.A[i]=A[i]-D2.A[i];
}
for(int i=BacDT+1;i<=D2.BacDT;i++)
D3.A[i]=D2.A[i] ;
D3.BacDT=D2.BacDT;
}
return D3;
}
void main()
{
CDaThuc A,B,C;
A.Nhap();
A.Xuat();
B.Nhap();
B.Xuat();
C=A+B;
C.Xuat();
getch();
}