日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

1269: GPA-一题简单英文题~

發布時間:2024/9/3 编程问答 30 豆豆
生活随笔 收集整理的這篇文章主要介紹了 1269: GPA-一题简单英文题~ 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

//很好奇AC率為啥這么低
1269: GPA
Time Limit: 1 Sec Memory Limit: 128 MB
Submit: 1064 Solved: 320
[Submit][Status][Web Board]
Description

In college, a student may take several courses. For each course i, he earns a certain credit(ci), and a mark ranging from A to F, which is comparable to a score(si), according to the following conversion table

A B C D F

4.0 3.0 2.0 1.3 0

The GPA is the weighted average score of all courses one student may take, if we treat the credit as the weight. In other words,

An additional treatment is taken for special cases. Some courses are based on “Pass/Not pass” policy, where students earns a mark “P” for “Pass” and a mark “N” for “Not pass”. Such courses are not supposed to be considered in computation. These special courses must be ignored for computing the correct GPA.

Specially, if a student’s credit in GPA computation is 0, his/her GPA will be “0.00”

Input

There are several test cases, please process till EOF.

Each test case starts with a line containing one integer N (1<N<100), the number of courses. Then follow N lines, each consists the credit and the mark of one course. Credit is a positive integer and less than 10.

Output

For each test case, print the GPA (rounded to two decimal places) as the answer.

Sample Input

4
2 B
2 P
1 F
3 A
2
2 P
2 N
6
4 A
3 A
3 A
4 A
3 A
3 A

Sample Output

3.00
0.00
4.00

HINT

For the first test case:

P/N is not considered.

Source

FDU
ACcode~:

#include <stdio.h> typedef struct gpa {double c;char s; }GPA; int main() {int n;while(~scanf("%d",&n)){GPA date[n];double sum = 0,num = 0,aver = 0;for(int i = 0; i < n; i++){scanf("%lf %c",&date[i].c,&date[i].s);switch(date[i].s){case 'A':sum += date[i].c*4.0;num += date[i].c;break;case 'B':sum += date[i].c*3.0;num += date[i].c;break;case 'C':sum += date[i].c*2.0;num += date[i].c;break;case 'D':sum += date[i].c*1.3;num += date[i].c;break;case 'F':num += date[i].c;break;}}if(sum)aver = sum / num;printf("%.2lf\n",aver);}return 0; }

總結

以上是生活随笔為你收集整理的1269: GPA-一题简单英文题~的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。