返回题解分享
讨论 / 题解分享/ 帖子详情

成绩分析(编程题) - 题解

题干有点问题
及格成绩:60
优秀成绩:85

#include <cstdio>

int main(){
    int n, x, mi = 0, mx = 0;
    scanf("%d", &n);
    int total = n;
    while(n--){
        scanf("%d", &x);
        if(x >= 60) mi++;
        if(x >= 85) mx++;
    }
    printf("%d%%\n", (int)(((float)mi / total) * 100 + 0.5)); 
    printf("%d%%\n", (int)(((float)mx / total) * 100 + 0.5));  
    return 0;
}
0 回复 0 转发 0 喜欢 1 阅读
回复 (0)
默认 最新
暂无回复,快来抢沙发!