#include "stdafx.h"
#define CLASSES 3
#define STUDENTS 5
#define GRADE 2

int main(int argc, char* argv[])
{
        int s[GRADE][CLASSES][STUDENTS] = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30};
        int clas, student, grade, total, subtotal, gradetotal;

        total = 0;
        
        for(grade = 0; grade< GRADE; grade++)
        {
                gradetotal = 0;

                for(clas = 0; clas < CLASSES; clas++)
                {
                        subtotal = 0;
                        for(student = 0; student < STUDENTS; student++)
                                subtotal += s[grade][clas][student];
                        printf("%d학년 학급 %d의 평균 성적 = %dn", grade, clas, subtotal/STUDENTS);
                        
                        total += subtotal;
                        gradetotal += total;
                }
                
                printf("%d학년 전체 학생들의 평균 성적 = %dn", grade, total/(CLASSES*STUDENTS));
        }
        printf("전교 평균 성적 = %dn", total/(GRADE*CLASSES*STUDENTS));

        return 0;
}


3차 배열을 통해 각 학년의 1~3학급별 평균 각각 구하고 1~2학년의 학년별 평균, 그리고 다시 전교 평균을 구하는 코딩인데 

학급별 평균이랑 전교 평균까진 잘나오는데 

학년 별 평균 에서 자꾸 답이 아닌 값이 나와요 

제발 구제좀 부탁드립니다