Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include <iostream>
- using namespace std;
- double f(const double x, int a[], const int i, const int max)
- {
- if (i + 1 < max)return f(x, a, i + 1, max)*x + a[i];
- else return a[max] * x + a[i];
- }
- int main()
- {
- int n, i;
- int a[100];
- double x;
- cout << "Введите кол-во элементов N: ";
- cin >> n;
- cout << "Введите переменную X: ";
- cin >> x;
- cout << "Введите [" << n << "] элементов: ";
- for (i = 0; i<n; i++) {
- cin >> a[i];
- }
- cout << f(x, a, 0, n - 1);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement