自己做的球二维多项式的C程序。有错误。请教一下大哥大姐,我不知道哪里错了。

来源:百度知道 编辑:UC知道 时间:2024/06/09 14:08:32
程序如下:
#include <stdio.h>
#include <conio.h>
double twoweidxs(double a[][],int n,double x,double y)
{ int i,j;
double b[20];
for(i=0;i<n;i++)
b[i]=a[i][0];
for(i=0;i<n-1;i++)
{ for(j=0;j<n-1;j++)
b[i]=b[i]*x+a[i][j+1];
}
for(i=0;i<n-1;i++)
b[0]=b[0]*y+b[i+1];
return b[0];
}
void main()
{ double a[3][3]={{3,1,2},{4,2,2},{1,2,2}};
double x,y;
int n=3;
printf("x,y fen bie shi:\n");
scanf("%lf\n",&x);
scanf("%lf\n",&y);
printf("jieguo=%lf",twoweidxs(a,n,x,y));
getch();
}
错误是:size of the type is unknown or zero.
到底哪里不对啊?
数组是横着为x,次数一次降低;竖着为y,次数依次降低。数组元素为交叉相乘项的系数。

#include <stdio.h>
#include <conio.h>

double twoweidxs(double** a,int n,double x,double y)
{ int i,j;
double b[20];
for(i=0;i<n;i++)
b[i]=a[i][0];
for(i=0;i<n-1;i++)
{ for(j=0;j<n-1;j++)
b[i]=b[i]*x+a[i][j+1];
}
for(i=0;i<n-1;i++)
b[0]=b[0]*y+b[i+1];
return b[0];
}
void main()
{
int i;
// double a[3][3]={{3,1,2},{4,2,2},{1,2,2}};
double ** a;
a=new double *[3];
for( i=0;i<3;i++)
{
a[i]=new double[3];
}
a[0][0]=3;
a[0][1]=1;
a[0][2]=2;
a[1][0]=4;
a[1][1]=2;
a[1][2]=2;
a[2][0]=1;
a[2][1]=2;
a[2][2]=2;

double x,y;
int n=3;
printf("x,y fen bie shi:\n");
scanf("%lf\n",&x);
scanf("%lf\n",&y);
printf("jieguo=%lf",twoweidxs(a,n,x,y));
getch();
}