#include <stdio.h>
#define M 4
#define N 4
//指向函数的指针
//将每个学生看成二维数组中的一个成员,成员是一个一维数组(二级页表与一集页表之间的区别)
int *index1(int (*ap)[N]);
void main()
{
int i, j, s[M][N], *p;
printf("Input scores for %d student:", M);
printf("Math,English,Programing,Computer\n");
for (i = 0; i < M; i++)
{
for (j = 0; j < N; j++)
{
scanf("%d", &s[i][j]);
}
printf("Input the [ %d ] one students",i);
}
//目的是为了获取相关学生的对应一级指针所指向的开始字节的地址
p = index1(s);
printf("The student's scores are below:\n ");
for (i = 0; i < N; i++)
{
printf("%d", *(p + i));
}
}
//将需要找出的额学生的内存地址又二级指针表示转化为直接使用一级指针表示
//传入的是一个int类型数字 的 数组 ====而不是传入int类型指针的数组
int *index1(int (*ap)[N])
{
int n;
printf("\nInput the order of a student:1-%d\n", M);
scanf("%d", &n);
//返回具体学生存储位置的首地址(不懂记得参考c primer plus 二维数组与指针部分)
return (*(ap + (n - 1)));
}
11.2.19-依次输出学生各科成绩,根据输入学号输出学生信息(一个二维数组例子)
猜你喜欢
转载自blog.csdn.net/qq_42664961/article/details/103979095
今日推荐
周排行