?? example_3.cpp
字號:
// Example_3.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "iostream.h"
int main(int argc, char* argv[])
{
float pointX;
float pointY;
int count=0;
float inputX;
double f=0;
printf("Input the number of the points!\n");
cin>>count;
double **points=new double*[count];
double *L=new double[count];
for(int k=0;k<count;k++)
{
points[k]=new double[2];
}
printf("Input the each points!\n");
for(int j=0;j<count;j++)
{
scanf("(%f,%f)",&pointX,&pointY);
points[j][0]=pointX;
points[j][1]=pointY;
}
cout<<"Input the value of the X:\nX=";
cin>>inputX;
for(int i=0;i<count;i++)
{
L[i]=1;
for(int t=0;t<count;t++)
{
if(t!=i)
{
L[i]=L[i]*(inputX-points[t][0])/(points[i][0]-points[t][0]);
}
}
f=f+L[i]*(points[i][1]);
}
printf("f(%.2f)=%f \n",inputX,f);
return 0;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -