caingocthanh Moderators
Tổng số bài gửi : 559 Join date : 27/04/2009 Age : 35 Đến từ : Cà Mau
| Tiêu đề: Tính giá trị hai đa thức tại một điểm !!! Thu Oct 29, 2009 12:03 am | |
| | | | | //tinh gia tri da thuc tai mot diem #include<conio.h> #include<iostream.h> #include<math.h> #define max 100 void nhapdathuc(float A[max],int n) { for(int i=0;i<=n;i++) { cout<<"nhap A["<<i<<"]="; cin>>A[i]; } } void xuatdathuc(float A[max],char *s,int n) { cout<<s<<"="<<A[0]; for(int i=1;i<=n;i++) { if(A[i]>=0) cout<<"+"<<A[i]<<"*x^"<<i; else cout<<A[i]<<"*x^"<<i; } } void giatridttmd(float A[max],int&x,int n) { float temp=A[0]; cout<<"nhap x="; cin>>x; for(int i=1;i<=n;i++) temp=temp+A[i]*pow(x,i); cout<<temp; } float gtdtmd(float A[max],int x,int n) { int temp =A[0]; for(int i=1;i<=n;i++) temp=temp+A[i]*pow(x,i); return temp; } void main() { float A[max],kq; int n,x; char*s; clrscr(); cout<<"nhap n="; cin>>n; cout<<"nhap x="; cin>>x; nhapdathuc(A,n); cout<<"Da thuc vua nhap"; cout<<endl; xuatdathuc(A,"p(x)",n); cout<<endl; // giatridttmd(A,x,n); theo thu tuc kq=gtdtmd(A,x,n);//theo ham cout<<kq; getch(); }
| | | | |
|
|