Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- #include <cstdlib>
- #include "p.h"
- using namespace std;
- Polynomial::Polynomial(unsigned int n)
- {
- coefficients=new double[n+1];
- degree=n;
- }
- Polynomial::~Polynomial()
- {
- delete coefficients;
- }
- void Polynomial:: setCoefficient(unsigned int i, double value){
- coefficients[i]=value;
- }
- double Polynomial::getCoefficient(unsigned int i){
- return coefficients[i];
- }
- double Polynomial:: value(double x)
- {
- double suma=0.0;
- for (int i=degree;i>=0;i--)
- suma+= coefficients[i]*pow(x,i);
- return suma;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement