c跟指针 数组

c和指针 数组1.?#include stdio.hvoid main(){int a[10]{1,2,3,4,5,6,7,9}printf(%x\n,a)printf(%

c和指针 数组

1.

?

#include <stdio.h>void main(){int a[10]={1,2,3,4,5,6,7,9};printf("%x\n",a);printf("%x\n",a+1);printf("%x\n",&a);}

?第一个输出和第三个输出相同。

a是指针常量,和普通指针变量有区别。&a好像没意义。&a应该写成&a[0]比较容易理解。

?

2.判断是否是单位矩阵

很好的代码:

for( row = 0; row < 10; row += 1 ){for( column = 0; column < 10; column += 1 ){/*** If the row number is equal to the column number, the** value should be 1, else 0.*/if( matrix[ row ][ column ] != ( row == column ) )return FALSE;}}return TRUE;
?