#include <stdio.h>
#include <stdlib.h>
void main( void )
{
int n;
float *x = NULL;
float *y = NULL;
float xFound;
float yGet = 0.0;
float yGetTemp = 1.0;
int client;
int temp;
printf("input how much x you wanna input,o~~");
scanf("%d",&n);
getchar();
printf("n=%d",n);
getchar();
x=(float *)malloc(sizeof(float)*n);
for (client=0;client<n;client++)
{
printf("input the x's date");getchar();
scanf("%f",(x+client));
}
y=(float *)malloc(sizeof(float)*n);
for (client=0;client<n;client++)
{
printf("input the y's date");getchar();
scanf("%f",(y+client));
}
for (client=0; client < n; client++)
{
for (temp = 0; temp < n; temp++)
{
if (temp == client)
continue;
else
yGetTemp *= ( (xFound - *(x + temp) ) / ( *(x + client) - *(x + temp) ) );
}
yGet += (yGetTemp * (*(y + client)));
yGetTemp = 1.0;
}
printf("The result is:%f", yGet);
}
我的程序一到输入X值那里就跳出来了,我感觉是内存分配问题,求解释啊!