fork download
  1. #include <stdio.h>
  2. #define STUDENTS 3
  3. #define EXAMS 4
  4.  
  5. int maximum(const int grades[][EXAMS]);
  6. int minimum(const int grades[][EXAMS]);
  7.  
  8. int main(void){
  9. int studentgrades[STUDENTS][EXAMS]={{77,68,86,73},{96,87,89,78},{70,90,86,81}};
  10.  
  11. printf("最高点:%d ",maximum(studentgrades));
  12. printf("最低点:%d ",minimum(studentgrades));
  13. return 0;
  14. }
  15.  
  16. int maximum(const int grades[][EXAMS]){
  17. int max=0;
  18. for(int i=0;i<STUDENTS;i++){
  19. for(int j=0;j<EXAMS;j++){
  20. if(grades[i][j]>max)
  21. max=grades[i][j];
  22. }
  23. }
  24. return max;
  25. }
  26.  
  27. int minimum(const int grades[][EXAMS]){
  28. int min=100;
  29. for(int i=0;i<STUDENTS;i++){
  30. for(int j=0;j<EXAMS;j++){
  31. if(grades[i][j]<min)
  32. min=grades[i][j];
  33. }
  34. }
  35. return min;
  36. }
Success #stdin #stdout 0s 5280KB
stdin
Standard input is empty
stdout
最高点:96 最低点:68