这个C程序运行后为什么自动关闭啊

来源:百度知道 编辑:UC知道 时间:2024/06/06 16:19:58
#include "stdio.h"
#include "math.h"
void fuction(int n,float x);
int main(void)
{
int n;
float x;
printf("The interval of x is [-1,1]\n\n");
printf("The second fuction is Lagrange polynomial.\n");
printf("Put down the number of node point:");
scanf("%d",&n);
do
{
printf("x=");
scanf("%f",&x);
fuction(n,x);
}
while(1);
getch();
return 0;
}
void fuction(int n,float x)
{
int i,a,b;
float X[5];
float y=0.00,p,m=1.00,A,B=1.00,l,Y;
for(i=0;i<=n;i++)
{
X[i]=-1+2*i/n;
}
for(a=0;a<=n;a++)
{
for(b=0;b<a;b++)
{
p=X[a]-X[b];
m=m*p;
A=x-X[b];
B=B*A;
}
for(b=a+1;b<=n;b++)
{
p=X[a]-X[b];

因为Windows会自动关闭已经执行完毕的窗口,
你可以在程序的最后加一句输入语句。如getch()。
另外程序的可读性太差,看了半天也没看明白你到底要计算什么多项式。写C程序适当的注释是必要的。
最重要的是没悬赏。