题解 | #学分绩点#挺无语的这题

学分绩点

https://www.nowcoder.com/practice/a0c09a7e0da04e728810a8aca7226b7b

#include <iostream>
using namespace std;

int main() {
    int credit[20];
    int score[20];
    int n;
    while (scanf("%d", &n) != EOF) { // 注意 while 处理多个 case
        double sum = 0;
        for(int i = 0; i < n; i++){
            scanf("%d", &credit[i]);
            sum += credit[i];
        }
        for(int i = 0; i < n; i++){
            scanf("%d", &score[i]);
        }
        double res = 0;
        for(int i = 0; i < n; i++){
            if(score[i] >= 90 && score[i] <= 100){
                res += 4.0 * credit[i];
            }else if(score[i] >= 90 && score[i] <= 100){
                res += 4.0 * credit[i];
            }else if(score[i] >= 85 && score[i] <= 89){
                res += 3.7 * credit[i];
            }else if(score[i] >= 82 && score[i] <= 84){
                res += 3.3 * credit[i];
            }else if(score[i] >= 78 && score[i] <= 81){
                res += 3.0 * credit[i];
            }else if(score[i] >= 75 && score[i] <= 77){
                res += 2.7 * credit[i];
            }else if(score[i] >= 72 && score[i] <= 74){
                res += 2.3 * credit[i];
            }else if(score[i] >= 68 && score[i] <= 71){
                res += 2.0 * credit[i];
            }else if(score[i] >= 64 && score[i] <= 67){
                res += 1.5 * credit[i];
            }else if(score[i] >= 60 && score[i] <= 63){
                res += 1.0 * credit[i];
            }else{
                res += 0;
            }
            
        }
        printf("%.2f", res / sum);
    }
}
// 64 位输出请用 printf("%lld")

全部评论

相关推荐

双非坐过牢:非佬,可以啊10.28笔试,11.06评估11.11,11.12两面,11.19oc➕offer
点赞 评论 收藏
分享
牛客771574427号:恭喜你,华杰
点赞 评论 收藏
分享
点赞 收藏 评论
分享
牛客网
牛客企业服务