3 3 92 5 80 2 60
2.90
#include <stdio.h>
double f(double p)
{
if(p >= 90) return 4;
if(p >= 80) return 3;
if(p >= 70) return 2;
if(p >= 60) return 1;
return 0;
}
int main()
{
int n;
double s, p, sums, sump;
while(scanf("%d", &n) != EOF){
sums = sump = 0;
while(n--){
scanf("%lf%lf", &s, &p);
if(p < 0) continue;
sums += s; sump += f(p) * s;
}
if(sump <= 0) printf("-1\n");
else printf("%.2lf\n", sump / sums);
}
return 0;
}HDU1202 The calculation of GPA,布布扣,bubuko.com
HDU1202 The calculation of GPA
原文:http://blog.csdn.net/chang_mu/article/details/38324749