标签:des style blog java color strong
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 18748 Accepted Submission(s): 4331
题目和思路都很简单,但坑也不少,WA了多少次,不记得了。
贴代码纪念一下:
#include <stdio.h> int main() { int n, k; double s, p, num, sum; double average; while(scanf("%d", &n)!=EOF) { num = 0; sum = 0; for(int i = 1; i<=n; i++) { scanf("%lf%lf", &s, &p); if(p != -1) { num += s; k = (int)(p); //将分数进行强制转换成int型 if(k>=90 && k<=100) { sum = sum + s*4.0; } else if(k>=80 && k<=89) { sum = sum + s*3.0; } else if(k>=70 && k<=79) { sum = sum + s*2.0; } else if(k>=60 && k<=69) { sum = sum + s*1.0; } } } if(sum == 0.0 || num == 0.0) //缺考和每门都考但不及格的 printf("-1\n"); else { average = sum*1.0/num; printf("%.2lf\n", average); } } return 0; }
hdu 1202The calculation of GPA (简单题+坑),布布扣,bubuko.com
hdu 1202The calculation of GPA (简单题+坑)
标签:des style blog java color strong
原文地址:http://www.cnblogs.com/fengxmx/p/3862293.html