#include<stdio.h>

void main(void)

{

int score[3][2][10]={{{85,90,75,30,58,60,100,45,70,48},

                       {75,65,75,30,50,65,50,55,40,-1}},

                      {{65,95,95,35,58,62,90,40,-1,-1},

                       {80,90,70,30,60,60,35,60,100,55}},

                      {{80,70,75,60,58,88,70,-1,-1,-1},

                       {10,90,80,30,45,32,65,90,70,-1}}};

 int total1[3][2],number1[3][2],total2[3],number2[3],total3=0,number3=0;

 float average1,average2,average3;

 int i,j,k;

 

 /* 初期化 */

 for(i=0;i<3;++i){

    for(j=0;j<2;++j){

       total1[i][j]=0;

       number1[i][j]=0;

    }

    total2[i]=0;

    number2[i]=0;

 }

 

 /* 各クラス毎の総点と総人数の計算 */

 for(i=0;i<3;++i){

    for(j=0;j<2;++j){

       for(k=0;k<10;++k){

          if(score[i][j][k]!=-1){

             total1[i][j]+=score[i][j][k];

             number1[i][j]+=1;

          }

       }

    }

 }

 

 /* 各クラスの平均点 */

 for(i=0;i<3;++i){

    for(j=0;j<2;++j){

       average1=(float)total1[i][j]/(float)number1[i][j];

       printf("Average of class %1d of grade %1d = %5.1f\n",j+1,i+1,average1);

    }

 }

 

 /* 各学年の平均点 */

 for(i=0;i<3;++i){

    for(j=0;j<2;++j){

       total2[i]+=total1[i][j];

       number2[i]+=number1[i][j];

    }

 }

 for(i=0;i<3;++i){

    average2=(float)total2[i]/(float)number2[i];

    printf("Average of grade %1d = %5.1f\n",i+1, average2);

 }

 

 /* 全平均点 */

 for(i=0;i<3;++i){

    total3+=total2[i];

    number3+=number2[i];

 }

 average3=(float)total3/(float)number3;

 printf("Average of all = %5.1f\n", average3);

}