首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C语言 >

关于二维数组的d调用,该如何处理

2013-08-01 
关于二维数组的d调用#include stdio.h#define FALSE 0#define TRUE 1 int identity_matrix(int *mat,int

关于二维数组的d调用
#include <stdio.h>
#define FALSE 0
#define TRUE 1

 int identity_matrix(int *mat,int size)
 {
int row,column;

for( row = 0; row < size; row += 1 )
{
for( column = 0; column < size; column += 1 )
{
if( *mat++ != ( row == column ) )
return FALSE;
}
return TRUE;
 }
 void main (void)
 {
 int matrix[4][4]={ {1,0,0,0},{0,1,0,0},{0,0,1,0},{0,0,0,1} };

 if(identity_matrix(&matrix[0][0],4)==TRUE)

 printf("this is a identity matrix\n");
 else 

    printf("this is not a identity matrix\n");
 }
加红的部分该如何写?一直在出错
F:\c程序\c和指针\identity_matrix\Cpp1.cpp(26) : error C2601: 'main' : local function definitions are illegal
F:\c程序\c和指针\identity_matrix\Cpp1.cpp(36) : fatal error C1004: unexpected end of file found
[解决办法]
错误提示已经指明了:函数定义错误。我刚才仔细看看来函数没错,仔细一看,自定义函数少个"}"

你的参数传递也没有错误!你可以直接使用指针(*(matrix + i) + j)

热点排行