题解 | #学分绩点#
学分绩点
https://www.nowcoder.com/practice/a0c09a7e0da04e728810a8aca7226b7b
#include <iostream> using namespace std; const int N=10; int a[N],grade[N]; int main() { int n; cin>>n; for(int i=0;i<n;i++) cin>>a[i]; for(int i=0;i<n;i++) cin>>grade[i]; double sum=0; for(int i=0;i<n;i++){ if(grade[i]>=90) sum+=a[i]*4.0; else if(grade[i]>=85) sum+=a[i]*3.7; else if(grade[i]>=82) sum+=a[i]*3.3; else if(grade[i]>=78) sum+=a[i]*3.0; else if(grade[i]>=75) sum+=a[i]*2.7; else if(grade[i]>=72) sum+=a[i]*2.3; else if(grade[i]>=68) sum+=a[i]*2.0; else if(grade[i]>=64) sum+=a[i]*1.5; else if(grade[i]>=60) sum+=a[i]*1.0; else sum+=0; } double k=0; for(int i=0;i<n;i++) k+=a[i]; printf("%.2lf",sum/k); return 0; }