找出下面10行代码中的错误,诺西的英文面试题,求个权威的标准答案,谢谢
c
int CalculateVectorProduct(const short*A,int size A,const short *B,int size B,int *Res )
{
int I;
Res =(int*)malloc(sizeA*sizeof(int));
if (sizeA!=sizeB)
{
return -1;
}
for(i=0;
{
*Res =(*A++)*(*B++);
}
}
int CalculateVectorProduct(const short*A,int size A,const short *B,int size B,int *Res )//“size A”应该是一个整体,不应该加空格, “size B”同理
{
int I;
Res =(int*)malloc(sizeA*sizeof(int));
if (sizeA!=sizeB)
{
return -1;
}
for(i=0;//for循环不完整,而且i没有声明,上面那个是大写I跟i不一样
{
*Res =(*A++)*(*B++);
}
}
int CalculateVectorProduct(const short *A, int sizeA,const short *B,int sizeB,int * Res )
{
if (sizeA!=sizeB)
return -1;
for(int i=0; i<sizeA;i++)
{
Res[i] = (int)A[i]*(int)B[i];
}
return 0;
}