Advertisement
Guest User

Untitled

a guest
Mar 28th, 2017
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.71 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. #include <cstdlib>
  4. #include "p.h"
  5.  
  6. using namespace std;
  7.  
  8.   Polynomial::Polynomial(unsigned int n)
  9.             {
  10.             coefficients=new double[n+1];
  11.             degree=n;
  12.             }
  13.     Polynomial::~Polynomial()
  14.         {
  15.         delete coefficients;
  16.         }
  17.     void Polynomial:: setCoefficient(unsigned int i, double value){
  18.         coefficients[i]=value;
  19.         }
  20.     double Polynomial::getCoefficient(unsigned int i){
  21.         return coefficients[i];
  22.         }
  23.     double Polynomial:: value(double x)
  24.         {
  25.         double suma=0.0;
  26.         for (int i=degree;i>=0;i--)
  27.             suma+= coefficients[i]*pow(x,i);
  28.         return suma;
  29.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement