Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <conio.h>
- #include <math.h>
- using namespace std;
- int factorial(int k)
- {
- if (k == 0) return 1;
- return k * factorial(k - 1);
- }
- double F(double x)
- {
- return log(x);
- }
- int main()
- {
- setlocale(LC_ALL, "Russian");
- int n;
- cout << "Введите кол-во узлов";
- cin >> n;
- //double x0;
- double *Xi = new double[n];
- double *Yi = new double[n];
- //double *K = new double[n];
- double X;
- double K;
- double H = 1, h, f;
- for (int i = 0; i < n; i++)
- {
- cout << "введите x" << "[" << i << "]" << ' ';
- cin >> Xi[i];
- }
- for (int i = 0; i < n; i++)
- {
- cout << "введите y" << "[" << i << "]" << ' ';
- cin >> Yi[i];
- }
- cout << "В какой точке посчитать";
- cin >> X;
- K = 0;
- for (int i = 0; i < n; i++)
- {
- f = 0;
- //H *= X-Xi[i-1];
- for (int j = 0; j <= i; j++)
- {
- h = 1;
- for (int k = 0; k <= i; k++)
- {
- if (k != j)
- h *= (Xi[j] - Xi[k]);
- }
- f += Yi[j] / h;
- //K+= H*f;
- }
- for (int k = 0; k < i; k++)
- f *= (X - Xi[k]);
- K += f;
- }
- cout << "Y[X]= " << K;
- system("pause");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement