【求助】大神们帮忙看看这段代码哪里有错。
要求:用二维数组记录3个班的学生的成绩,并统计最高分成绩和对应学号其中附加要求:使用一维操作方式(注意标红表达式)操作二维数组
程序代码:
#include <stdio.h> #define CLASS 3 #define ARR_SIZE 40 int FindMax(int *score, int n, int m, int *pRow, int *pCol); int main(void) { int score [CLASS][ARR_SIZE], i, n, maxScore, row, col; printf("Please enter student number in a class:"); scanf("%d", &n); printf("Please enter score: \n"); for (i=0; i<CLASS*n; i++) { scanf("%d", &(*(score+i)) ); } maxScore=FindMax((int*)score,n,CLASS,&row,&col ); printf("maxScore = %d, class= %d, number = %d\n", maxScore, row+1, col+1); } int FindMax(int *score, int n, int m, int *pRow, int *pCol) { int i, maxScore; maxScore = *(score) ; *pRow = 0; *pCol = 0; for (i=0; i<m*n; i++) { if (*(score+i) >maxScore ) { maxScore = *(score+i); *pRow= i/n; *pCol= i%n; } } return(maxScore); }