Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- void wpisz(double T[], int n)
- {
- cout << "podaj wspolczynniki wielomianu: " << endl;
- for (int i=0;i<=n;i++)
- {
- cout<<"podaj wspolczynnik "<<i<<": ";
- cin>>T[i];
- }
- cout<<endl;
- }
- double oblicz(double A[],int n, double x )
- {
- double w=A[0];
- for(int i=1;i<=n;i++)
- {
- w=w*x+A[i];
- }
- return w;
- }
- double obliczrek(double A[],int n, double x )
- {
- if(n==0)
- {
- return A[0];
- }
- else
- {
- return obliczrek(A, n-1,x)*x +A[n];
- }
- }
- int main()
- {
- int n;
- cout << "Podja stopien wielominau: ";
- cout<<endl;
- cin>>n;
- cout<<endl;
- double Tab[n+1];
- wpisz(Tab,n);
- double x;
- cout<<"podaj argument x: ";
- cin>>x;
- cout<<endl;
- cout<<"Wynik to: "<<obliczrek(Tab,n,x)<<endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement