October 2018 1 16 Report

Czy mogl by mi ktos pomoc i zrobic zeby sie kompilowalo bo juz nie mam sily.

#include <cstdlib>
#include <iostream>

using namespace std;

public static double Lagrangea(double xTab[], double yTab[], double x, int n)
{
double t = 1.0;
double y = 1.0;

for (int k = 0; k < n; k++)
{
t = 1.0;
for (int j = 0; j < n; j++)
{
if (j != k)
{
t = t * ((x - xTab[j]) / (xTab[k] - xTab[j]));
}

}
y += t * yTab[k];
}

return y;
}

int main(int argc, char *argv[])
{
cout<<"Podaj liczbę wezlow: \n";

int ilosc;
cin>>ilosc;

double xTab[ilosc];
double yTab[ilosc];

for( int i = 0; i < ilosc; i++)
{
cout<<"Podaj wartosc wezla nr" + i+1;
cin>>xTab[i];

cout<<"Podaj wartosc funkcji nr" + i+1;
cin>>yTab[i];
}

//chcemy znaleźć wartość w x = 2
double y2 = lagrangeInterpolation(x,y,1);
cout << "y = " << y2 << endl;
system("PAUSE");
return EXIT_SUCCESS;
}


Recommend Questions



Life Enjoy

" Life is not a problem to be solved but a reality to be experienced! "

Get in touch

Social

© Copyright 2013 - 2024 KUDO.TIPS - All rights reserved.