用数组编的多项式乘法,但是不会合并同类项
从同学那参考了合并的方法,但是有错误
比较着急!!
下面是程序
#include
#define N 100
void multiply(int a[],int b[], int a,int b)
{
int i,j,s=a+b;
int c[N]={0};
for(i=0;i<=a;i++)
for(j=0;j<=b;j++)
c[i+j]+=a[i]*b[j];
printf("a(x)*b(x)=");
for(i=s;i>=1;i--)
printf("%dx^%d+",c[i],i);
printf("%d\n",c[0]);
}
void main()
{
int i,j,k=0;
int m=0,n=0;
int a[50],b[50],c[2500];
printf("Please input the highest exponencial of A\n");
scanf("%d",&m);
printf("Please input the coefficient of A\n");
for(i=0;i
scanf("%d",&a[i]);
printf("Please input the highest exponencial of B\n");
scanf("%d",&n);
printf("Please input the coefficient of B\n");
for(j=0;j
scanf("%d",&b[j]);
multiply(a[],b[],m,n);
}
这是错误
c(3) : error C2040: 'a' : 'int ' differs in levels of indirection from 'int *'
c(3) : error C2040: 'b' : 'int ' differs in levels of indirection from 'int *'
c(5) : error C2110: cannot add two pointers
c(7) : warning C4047: '<=' : 'int ' differs in levels of indirection from 'int *'
c(8) : warning C4047: '<=' : 'int ' differs in levels of indirection from 'int *'
c(30) : error C2059: syntax error : ']'
求大神指点啊,这个作业我都写了半个多月了,本人比较脑残,开始是用链表和结构体编的,但是实在编不出来,然后就编了这个,是把多项式的系数放到了数组里,可是又不会合并。。。