Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main(){
- int n; //
- double xp; //
- double yp=0.0;
- cout<<"n=";
- cin>>n;
- double x[n];
- double y[n];
- for (int l=0;l<n;l++){
- cout<<"x_"<<l<<" || y_"<<l<<endl;
- cin>>x[l]>>y[l];
- }
- for (int l=0;l<n;l++){
- cout<<"x_"<<l<<"="<<x[l]<<" || y_"<<l<<"="<<y[l]<<endl;
- }
- cout<<"approximation point:xp=";
- cin>>xp;
- double P;//
- for (int i = 0;i<n;i++){
- P=1.0;
- for (int k=0;k<n;k++){
- if(i!=k){
- P*=(xp-x[k])/(x[i]-x[k]);
- }
- }
- yp+=P*y[i];
- }
- cout<<"xp="<<xp<<endl;
- cout<<"yp="<<yp<<endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement