Advertisement
JosepRivaille

Problem P96767: Avaluació de polinomis (1)

Mar 14th, 2015
931
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.30 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4.  
  5. //Pre: Llegeix els coeficients ordenats d'una polinomi
  6. //Post: La resol per a un valor
  7. int main() {
  8.     cout.setf(ios::fixed);
  9.     cout.precision(4);
  10.     double x, n, p=1, r;
  11.     cin >> x >> r;
  12.     while (cin >> n) {
  13.         p = p*x;
  14.         r = r + n*p;
  15.     }
  16.     cout << r << endl;
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement