1080 MOOC期终成绩 (25 分)
對于在中國大學MOOC(http://www.icourse163.org/?)學習“數據結構”課程的學生,想要獲得一張合格證書,必須首先獲得不少于200分的在線編程作業分,然后總評獲得不少于60分(滿分100)。總評成績的計算公式為?0,如果?G?mid?term??>G?final??;否則總評?G?就是?G?final??。這里?G?mid?term???和?G?final???分別為學生的期中和期末成績。
現在的問題是,每次考試都產生一張獨立的成績單。本題就請你編寫程序,把不同的成績單合為一張。
輸入格式:
輸入在第一行給出3個整數,分別是 P(做了在線編程作業的學生數)、M(參加了期中考試的學生數)、N(參加了期末考試的學生數)。每個數都不超過10000。
接下來有三塊輸入。第一塊包含 P 個在線編程成績?G?p??;第二塊包含 M 個期中考試成績?G?mid?term??;第三塊包含 N 個期末考試成績?G?final??。每個成績占一行,格式為:學生學號 分數。其中學生學號為不超過20個字符的英文字母和數字;分數是非負整數(編程總分最高為900分,期中和期末的最高分為100分)。
輸出格式:
打印出獲得合格證書的學生名單。每個學生占一行,格式為:
學生學號?G?p???G?mid?term???G?final???G
如果有的成績不存在(例如某人沒參加期中考試),則在相應的位置輸出“?”。輸出順序為按照總評分數(四舍五入精確到整數)遞減。若有并列,則按學號遞增。題目保證學號沒有重復,且至少存在1個合格的學生。
輸入樣例:
6 6 7 01234 880 a1903 199 ydjh2 200 wehu8 300 dx86w 220 missing 400 ydhfu77 99 wehu8 55 ydjh2 98 dx86w 88 a1903 86 01234 39 ydhfu77 88 a1903 66 01234 58 wehu8 84 ydjh2 82 missing 99 dx86w 81輸出樣例:
missing 400 -1 99 99 ydjh2 200 98 82 88 dx86w 220 88 81 84 wehu8 300 55 84 84 #include<iostream> #include<vector> #include<algorithm> #include<map> using namespace std;struct Node{string name;int gp,gm,gf,g; }node;bool cmp(Node a,Node b){return a.g != b.g ? a.g > b.g : a.name < b.name; }int main(){map<string,int>idx; //to judge whether the student exists or notvector<Node> ans,stu;int p,n,m;cin >> p >> m >> n;string s;int score,cnt = 1;for(int i = 0; i < p; i++){cin >> s >> score;if(score >= 200){node.name = s;node.gp = score;node.gm = -1;node.gf = -1;node.g = 0;stu.push_back(node);idx[s] = cnt++;}} for(int i = 0; i < m; i++){cin >> s >> score;if(idx[s] != 0){stu[idx[s] - 1].gm = score;}}for(int i = 0; i < n; i++){cin >> s >> score;if(idx[s] != 0){int temp = idx[s] - 1;stu[temp].gf = score;stu[temp].g = score;if(stu[temp].gm > stu[temp].gf)stu[temp].g = int(stu[temp].gm * 0.4 + score * 0.6 + 0.5);}}for(int i = 0; i < stu.size(); i++){if(stu[i].g >= 60) ans.push_back(stu[i]);}sort(ans.begin(),ans.end(),cmp);for(int i = 0; i < ans.size(); i++){printf("%s %d %d %d %d\n",ans[i].name.c_str(),ans[i].gp,ans[i].gm,ans[i].gf,ans[i].g);}return 0; }?
轉載于:https://www.cnblogs.com/wanghao-boke/p/10424589.html
總結
以上是生活随笔為你收集整理的1080 MOOC期终成绩 (25 分)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 前端开发应该如何应用自动化呢? 财
- 下一篇: 1078 字符串压缩与解压 (20 分)