📄 aitken.cpp
字号:
//Aitken's formula
#include<stdio.h>
#include<conio.h>
void main()
{
int n,m,i,j;
float x,y,q1,q2,a[10][10];
char c;
NEWAIT:
printf("enter the value of n:");
scanf("%d",&n);
m=n;
printf("enter the values of x:");
for(i=0;i<n;i++){
scanf("%f",&a[i][0]);
}
printf("enter the values of y:");
for(i=0;i<n;i++){
scanf("%f",&a[i][1]);
}
AIT:printf("enter the value of x for which to calculate y:");
scanf("%f",&x);
/*calculation of y */
y=0;
for(j=1;j<n;j++){
for(i=0;i<(n-j);i++){
q1=a[0][j]*(a[j+i][0]-x);
q2=a[i+1][j]*(a[j-1][0]-x);
a[i][j+1]=(q1-q2)/(a[i+j][0]-a[j-1][0]);
y=a[i][j+1];
}
}
printf("\nDifference Table:\n");
/*printing of table*/
for(j=0;j<n;j++){
for(i=0;i<m+1;i++){
printf("%.5f ",a[j][i]);
}
m=m-1;
printf("\n");
}
printf("\ny=%.5f\n",y);
printf("\nTo give different value of x for same data, press 1");
printf("\nTo give different set of data press 2");
printf("\nTo exit press 0\n");
c=getch();
if(c=='1')
goto AIT;
if(c=='2')
goto NEWAIT;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -