题解 | #学分绩点#挺无语的这题
学分绩点
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")