#define _CRT_SECURE_NO_WARNINGS
//例子8.13 输出二维数组 任一行任一列元素的值
//最近怎么这么困..
#include<stdio.h>
int main()
{
int a[2][3] = { {1,2,1},{3,4,3}};
int(*p)[3] = a;//指针,指向一个一维数组,每行有3个元素;
int x, y;
scanf("%d,%d", &x, &y);
printf("%d", *(*(p + x) + y));
}
//例子8.14 一个班,3名学生,各学四门课,计算总平均分数,第n个学生成绩
// 二维数组,
// 总平均分,所有成绩加起来
#include<stdio.h>
void aver(int(*p)[4])
{
int i, j, sum = 0;
for (i = 0; i < 3; i++)
for (j = 0; j < 4; j++)
sum += *((*p + i) + j);
printf("总平均分是%d", sum / 12);
}
int main()
{
int a[3][4] = { {1,2,3,4},{4,5,6,7},{2,4,5,7} };
//int(*p)[4]=a;
//aver(p);
aver(a);
}