将3位学生4门课成绩读入并存储在二维数组score中

将3位学生4门课成绩读入并存储在二维数组score中
将3位学生4门课成绩读入并存储在二维数组score中,然后输出第n(约定n<=2)个学生的成绩,要求用户编程部分对数组score及其元素的访问必须使用指针实现,即自定义函数头和函数体中不得出现数组下标形式的表示法。
编程可用素材:printf("\nthe score of No %d are:"…、printf("%6.1f"…。

#include

#define N 3

#define M 4

using namespace std;

int main()

{

int score[N][M];

int i,j;

cout<<"请输入孙运让您的数组:"<

//首先输入你悄态的数组

for (i=0;i

{

for (j=0;j

{

cin>>score[i][j];

}

}

int (*p)[M]=score;

cout<<"请输入您要查询的学生的序号(0,1,2):"<

int n;

cin>>n;

p=&score[n];

cout<<"第"<

//下面是输出你的数组,完全指针

for (int *q=*p;q!=*p+4;q++)

{

cout<<*q<<" ";

}

cout<

return 0;

}


int score[3][4];
for(int i = 0 ; i <薯闹 3)
for(int j = 0 ; j <数李罩扰此 4 ; j ++)
{
scanf("%d" , score);
score++;
}
← 上一篇: 下一篇: →