#include <stdio.h>
#include <stdlib.h>
int main()
{    
    double AVERAGE(float score[5]);
    double grade[5][3];
    int i, j;
    double h[5];
    double k;
    double average1;
    printf("==========================welcome to the system=============================\n");
    for (i = 1; i <= 5; i++)
    {
        for (j = 1; j <= 3; j++)
        {
            printf("===input the %dth subject grade of the %dth student===\n", j , i );
            aa:scanf_s("%f", &k);
            if (k <= 100 && k >= 0)
            {
                grade[i][j] = k;
            }
            else
            {
                printf("input the right grade!\n");
                goto aa;
            }
        }
    }
    printf("==========subject1========subject2========subject3==\n");
    for (i = 1; i <= 5; i++)
    {
        printf("student%d      %f            %f                %f\n", i, grade[i][1], grade[i][2], grade[i][3]);
    }
    printf("====================================================\n");
    for (i = 1; i <= 5; i++)
    {
        h[i] = grade[i][1];
    }
    average1 = AVERAGE(h[5]);
    printf("%f", average1);
    system("pause");
    return 0;
}
double AVERAGE(double score[5])
{
    int x;
    double aver, sum = score[0];
    for (x = 1; x <= 5; x++)
        sum = sum + score[x];
    aver = sum / 10;
    return(aver);
}

 

扫码关注我们
微信号:SRE实战
拒绝背锅 运筹帷幄

SRE实战 互联网时代守护先锋,助力企业售后服务体系运筹帷幄!一键直达领取阿里云限量特价优惠。