写一个算法出现了一个错误不知道怎么改,请大家指导一下。
#include<stdio.h>#include<stdlib.h>
int main(void)
{
int marr1[3][4]={
{1,2,3,4},
{5,6,7,8},
{9,10,11,12}
};
int arr2[12]={0};
int row,column,i,arr1;
printf("原二维资料:\n");
for(row=0;column<4;column++)
{
printf("%4d",arr1[row][column]);
}
printf("\n");
{
printf("\n以列为主:");
for(column=0;column<4;column++)
{
i=column+row*4;
arr2[i]=arr1[row][column];
}
}
for(i=0;i<12;i++)
printf("%d",arr2[i]);
printf("\n以列为主:");
for(row=0;row<3;row++)
{
for(column=0;column<4;column++)
{
i=row+column*3;
arr2[i]=arr1[row][column];
}
}
for(i=0;i<12;i++)
printf("%d",arr2[i]);
printf("\n");
return0;
}
错误显示:
E:\CYUYUAN\78456\78456.c(15) : error C2109: subscript requires array or pointer type
E:\CYUYUAN\78456\78456.c(15) : error C2109: subscript requires array or pointer type
E:\CYUYUAN\78456\78456.c(23) : error C2109: subscript requires array or pointer type
E:\CYUYUAN\78456\78456.c(23) : error C2109: subscript requires array or pointer type
E:\CYUYUAN\78456\78456.c(34) : error C2109: subscript requires array or pointer type
E:\CYUYUAN\78456\78456.c(34) : error C2109: subscript requires array or pointer type
E:\CYUYUAN\78456\78456.c(40) : error C2065: 'return0' : undeclared identifier
执行 cl.exe 时出错.
78456.obj - 1 error(s), 0 warning(s)
这是一个多维矩阵转一维的程序