题解 | #公务员面试#

公务员面试

http://www.nowcoder.com/practice/f3a134908d5b41869f14f58307008a97

#include <stdio.h>
#include <math.h>
int main()
{
    float sum = 0;
    int grade [7] = {0};
    scanf("%d %d %d %d %d %d %d",&grade[0],&grade[1],&grade[2],&grade[3],&grade[4],&grade[5],&grade[6]);
    //冒泡排序 决出最大值最小值
    for(int i = 0; i < 6; i++)
    {
        for (int j = 0; j < 6 - i; j++)
        {
            if (grade[j] > grade[j+1])
            {
                int temp = grade[j];
                grade[j] = grade[j+1];
                grade[j+1] = temp;
            }
        }
    }
    for (int i = 1; i < 6; i++)
    {
        sum += grade[i];
    }
    double pin = sum / 5.0;
    printf("%.2lf",pin);
    
    return 0;
}
全部评论

相关推荐

点赞 评论 收藏
分享
点赞 收藏 评论
分享
牛客网
牛客企业服务