Advertisement
Guest User

Untitled

a guest
Oct 17th, 2016
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.56 KB | None | 0 0
  1. #include "stdafx.h"
  2.  
  3.  
  4. #include <iostream>
  5.  
  6. using namespace std;
  7.  
  8. double f(const double x, int a[], const int i, const int max)
  9. {
  10.     if (i + 1 < max)return f(x, a, i + 1, max)*x + a[i];
  11.     else return a[max] * x + a[i];
  12. }
  13. int main()
  14. {
  15.  
  16.  
  17.     int n, i;
  18.     int a[100];
  19.     double x;
  20.     cout << "Введите кол-во элементов N: ";
  21.     cin >> n;
  22.     cout << "Введите переменную X: ";
  23.     cin >> x;
  24.     cout << "Введите [" << n << "] элементов: ";
  25.     for (i = 0; i<n; i++) {
  26.         cin >> a[i];
  27.     }
  28.     cout << f(x, a, 0, n - 1);
  29.     return 0;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement