Thông tin tài liệu
!
"#!$%"&$ '()**+,)*-).
"/01!23 45
6/0784984:6"
;<=>?/@0,0-A
BC DCE DFG
H!IJKLJC
!"
int USCLN(p, q)
{
if (p%q= =0)
return q;
else
return(USCLN(q, p%q));
}
#
$%&'(#()(
,*+, /0,!1%&'("23
2$456$+7689$2$45:;
<=>2 ?!2$456"++7@
=A4B"++2$45C2,!"+2$45<+"232$
456+78
,*+, /0,!1%&'##(0&
%&'?!@C$+7==B$603
D+E6?!B=B$"F2+7==8G
603=D++H!B6"+=8@=A
60
,*+, /0,!1%&'))(=2"+
D+!"I
→
GJ"K4B0LM
N BOI,!"+P2:=860
N BOG,!"++7=860
Q
Q
Q
B2%&'6$, /PM
,RGSTUVW(XGYSYTUUYVZ
[4M\]
^[8M_XGZ
^`HTUV,!+7==8"!YTUUYV
^TB?HR=+%&')"!R+%&
'#
Q
,R#GSTW(#XGSYWTYSYGSTZ
^[8M_aGSbW_#aGTbW_)ab
,!$=B$
^`HR#=8+7==B$:R#&')
Q
,R)V*` cW()XVYWVY WVYcW*Y`W
cY*Z
^_B$6R,!V
^[+7==B$,!*` c
^TB$D+!"VY*WVY`WVYWVY WV
Yc,!$D+!"E6:, /R&
%&'#R=%&%&')
Q
'
#include <conio.h>
#include <iostream.h>
#include <math.h>
class DT
{
private:
double a[20];// Mang chua cac he so da thuc
a0, a1,
int n ;// Bac da thuc
public:
void nhap();
void hienthi();
DT operator-(const DT &d2);
double operator^(double x);// Tinh gia tri
da thuc
};
#Q
void DT::hienthi()
{
cout<<a[0]<<"X^0";
for (int i=1 ;i<= n ;++i)
cout<<"+"<< a[i] <<"X^"<<i ;
}
#Q
[4M#\]
void DT::nhap()
{
cout << "Bac da thuc:";
cin >> n;
cout << "Nhap cac he so da thuc:" ;
for (int i=0 ;i<=n ;++i)
{
cout << "\n He so bac"<<i<<":" ;
cin >> a[i] ;
}
}
#Q
DT DT::operator-(const DT &d2)
{
DT d;
int k,i;
k = (n > d2.n)?n:d2.n ;
for (i=0;i<=k ;++i)
if (i<=n && i<=d2.n)
d.a[i] = a[i] - d2.a[i];
else
if (i<=n)
d.a[i] =a[i];
else
d.a[i] = -d2.a[i];
i = k;
while (i>0 && d.a[i]==0.0) i;
d.n=i;
return d ;}
dQ
double DT::operator^(double x)
{
double s=0.0 , t=1.0;
for (int i=0 ;i<= n ;++i)
{
s+= a[i]*t;
t *= x;
}
return s;
}
#Q
[4M)\]
void main()
{
DT p,q,f;
double x,g;
clrscr();
cout <<"\n Nhap da thuc P :" ;p.nhap();
cout <<"\n Nhap da thuc Q :" ;q.nhap();
cout << "\n Nhap so thuc x :" ;cin >> x;
f = (p-q);
g = f^x;
cout << "\n Da thuc f ";
f.hienthi();
cout<<"\n x =" << x;
cout << "\n f(x) = "<<g;
getch();
}
#Q
E(.
H!ILM
#
e
E(.
NEE(O.
eee!eee$eef"eee
[4M]\]
. (int i=1 ;i < = n ;++i)
cout < < "+" < < a[i] < < "X^" < < i ;
}
#Q
[4M#]
void DT::nhap()
{
cout < < "Bac. n;
cout < < "Nhap cac he so da thuc:" ;
for (int i=0 ;i < =n ;++i)
{
cout < < "
He so bac" < < i < < ":"
Ngày đăng: 19/03/2014, 02:44
Xem thêm: đáp án đề thi lí thuyết tốt nghiệp khóa 3 - lập trình máy tính - mã đề thi ltmt - lt (18)