指针和数组
#include <stdio.h>
#include <stdlib.h>
int main(){
/*
//c语言的定义是这样的
int a = 5;
int *p;
p = &a;
//为了简洁性
int *p1 = &a;
printf("%x\n",p1);
printf("%x\n",p);
//两个指针指向同一个地址
int *p2;//野指针不是空指针
int *p3 = NULL;//空指针
//指针的兼容性
int a1 = 0x12345;
char *p4 = &a1;
//p4++;
printf("%x",*p4);
//这时候只打印出来了45;类型char只读取了两个字节45
*/
//数组的求和问题
int a7[2][5] = { { 1, 2, 3, 4, 5 }, { 6, 7, 8, 9, 10 } };
//普通解法
int sum = 0; int sum2 = 0, m = 0, n = 0;
for (; m < 5; m++){
// sum += a7[0][m];
sum2 += a7[1][m];
sum += *(*(a7 + 1) + m);//指针的解法
}
sum = sum / m;
sum2 = sum2 / m;
printf("%d\n",sum);
printf("%d\n", sum2);
system("pause");
return 0;
}