#include #include #include #include using namespace std; float first(vector>tmp, int i) { return ((tmp[i+1].second - tmp[i].second) / (tmp[i+1].first - tmp[i].first)); } float Newton(vector>tmp, int k, int i) { if(k == 0) { return 1; } if(k == 1) { return first(tmp, i); } return (Newton(tmp, k - 1, i + 1) - Newton(tmp, k - 1, i)) / (tmp[i+k].first - tmp[i].first); } int main() { vector>tmp; fstream plik; plik.open("dane", fstream::in); if(plik.good()) { int n; plik >> n; cout<<"Ilosc wezlow: "<> x; plik >> y; tmp.push_back(make_pair(x,y)); } for(int m=0; m>q; float result = tmp[0].second; float pomocnicza = 0; for (int i = 0; i < n; i++) { pomocnicza = 0; for (int j = 0; j < i; j++) { if (j == 0) { pomocnicza = q - tmp[0].first; } else { pomocnicza *= q - tmp[j].first; } } result += pomocnicza*Newton(tmp,i,0); } cout<