fork download
  1. #include <stdio.h>
  2. #define STUDENTS 3
  3. #define EXAMS 4
  4.  
  5. int maximum( const int grades[][EXAMS], int pupils, int tests );
  6. int minimum( const int (*grades)[EXAMS], int pupils, int tests );
  7.  
  8. int main(void)
  9. {
  10. int studentGrades[STUDENTS][EXAMS] = { {77,68,86,73},
  11. {96,87,89,78},
  12. {70,90,86,81} };
  13.  
  14. printf("maximum : %d\n", maximum( studentGrades, STUDENTS, EXAMS ) );
  15. printf("minimum : %d\n", minimum( studentGrades, STUDENTS, EXAMS ) );
  16.  
  17. return 0;
  18. }
  19.  
  20. int maximum( const int grades[][EXAMS], int pupils, int tests )
  21. {
  22. int high_grade = 0;
  23.  
  24. for(int i=0; i<pupils; i++){
  25. for(int j=0; j<tests; j++){
  26. if(grades[i][j] > high_grade)
  27. high_grade = grades[i][j];
  28. }
  29. }
  30. return high_grade;
  31. }
  32.  
  33. int minimum( const int (*grades)[EXAMS], int pupils, int tests )
  34. {
  35. int low_grade = 100;
  36.  
  37. for(int i=0; i<pupils; i++){
  38. for(int j=0; j<tests; j++){
  39. if(grades[i][j] < low_grade)
  40. low_grade = grades[i][j];
  41. }
  42. }
  43. return low_grade;
  44. }
Success #stdin #stdout 0.01s 5288KB
stdin
Standard input is empty
stdout
maximum : 96
minimum : 68