📄 cpp1.cpp
字号:
#include<stdio.h>
#include<math.h>
void main()
{
int i,k,j,t;float y[5][5]={0},a[5],x0;
printf("Input 5 points xi:");
for(i=0;i<5;i++)
scanf("%f",&a[i]);
printf("the 5 value of points:");
for(j=0;j<5;j++)
scanf("%f",&y[j][j]);
printf("the number x0 need to compute");
scanf("%f",&x0);
for(k=0;k<4;k++)
{
for(i=0,j=k+1;i<4,j<=4;i++,j++)
{
y[i][j]=y[i+1][j]+(y[i][j-1]-y[i+1][j])*(x0-a[j])/(a[i]-a[j]);
if(i>0&&fabs(y[i][j]-y[i-1][j-1])<1.e-6)
{t=1;break;}
}
if(t==1)break;
}
printf("f(x0)=%f,函数的次数为:%d\n",y[i-1][j-1],k);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -