đá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)

4 157 2
đá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)

Đang tải... (xem toàn văn)

Thông tin tài liệu

   !  "#!$%"&$ '()**+,)*-). "/01!23 45 6/0784984:6" ;<=>?/@0,0-A BC DCE DFG H!IJKLJC       !" int USCLN(p, q) { if (p%q= =0) return q; else return(USCLN(q, p%q)); }  # $%&'(#()( ,*+, /0,!1%&'("23 2$456$+7689$2$45:; <=>2 ?!2$456"++7@ =A4B"++2$45C2,!"+2$45<+"232$ 456+78 ,*+, /0,!1%&'##(0& %&'?!@C$+7==B$603 D+E6?!B=B$"F2+7==8G 603=D++H!B6"+=8@=A 60 ,*+, /0,!1%&'))(=2"+ D+!"I → GJ"K4B0LM N BOI,!"+P2:=860 N BOG,!"++7=860 Q Q Q B2%&'6$, /PM ,RGSTUVW(XGYSYTUUYVZ [4M\] ^[8M_XGZ ^`HTUV,!+7==8"!YTUUYV ^TB?HR=+%&')"!R+%& '# Q ,R#GSTW(#XGSYWTYSYGSTZ ^[8M_aGSbW_#aGTbW_)ab ,!$=B$ ^`HR#=8+7==B$:R#&') Q ,R)V*` cW()XVYWVY WVYcW*Y`W  cY*Z ^_B$6R,!V ^[+7==B$,!*` c ^TB$D+!"VY*WVY`WVYWVY WV Yc,!$D+!"E6:, /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 [4M#\] 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 [4M)\] 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!ILM  # e E(. NEE(O. eee!eee$eef"eee [4M]\] . (int i=1 ;i < = n ;++i) cout < < "+" < < a[i] < < "X^" < < i ; } #Q [4M#] 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

Tài liệu cùng người dùng

  • Đang cập nhật ...

Tài liệu liên quan