Problem F: 来算一下自己的成绩吧!
2017-05-13 13:42
274 查看
Home | Web Board | ProblemSet | Standing | Status | Statistics |
Problem F: 来算一下自己的成绩吧!
Time Limit: 1 Sec Memory Limit:128 MB
Submit: 1269 Solved: 529
[Submit][Status][Web
Board]
Description
OJ是一个同学们又爱又恨的东东。老师在OJ上布置了作业,并且把作业成绩作为实验课程的成绩。马上就要结课了,小明想知道自己到底能得到多少分,所以他向老师请教分数的计算方法。老师告诉他,分数是这么算滴:1. 对于某次作业,假设所有同学中Accpted题目数最多为X,小明Accpted题目数为Y,那么这次作业小明得分100Y/X。
2. 如果小明不幸错过了某次作业或者没有题目被Accpted,那么为0分。
3. 最终成绩是所有作业成绩的平均分。
好了,小明从OJ上下载了所有的standing,发现要想计算成绩还是挺麻烦的。所以,他向你求助,请你帮忙编个程序,算算分数。
Input
第1行N>0,表示本年级、本专业的学生数。之后N行,每行是一个不含空白符的字符串,是一个学生的名字(假定没有重名,且姓名最多有10个字符)。
接着是M>0,表示老师总共布置的作业次数。
每次作业的输入中,第1行K>0,表示这次作业的standing中有提交记录的学生人数。之后K行是K个学生的姓名及其Accpted的题目数。
Output
第1行输出:NAME TEST1 TEST2 TEST3 ...... FINAL。其中,“TEST?”的个数等于作业次数,按照顺序依次输出,如上所示。
之后根据输入的专业学生姓名顺序,依次输出所有学生的每次作业成绩以及最终成绩。
所有输出左对齐。
成绩保留2位小数,且左对齐输出。
输出的每一列的第1个字符要对齐。
见样例。
Sample Input
5zhangsanlisiwangwuliuliudingqi32zhangsan 4lisi 85zhangsan 11lisi 7wangwu 4liuliu 3dingqi 43zhangsan 3lisi 10wangwu 7Sample Output
NAME TEST1 TEST2 TEST3 FINALzhangsan 50.00 100.00 30.00 60.00 lisi 100.00 63.64 100.00 87.88 wangwu 0.00 36.36 70.00 35.45 liuliu 0.00 27.27 0.00 9.09 dingqi 0.00 36.36 0.00 12.12HINT
Append Code
[Submit][Status][WebBoard]
한국어< 中文 فارسی English ไทย
All Copyright Reserved 2010-2011
SDUSTOJ TEAM
GPL2.0 2003-2011
HUSTOJ Project TEAM
Anything about the Problems, Please Contact Admin:admin
#include <iostream> #include <iomanip> using namespace std; class Student { private: string name; double *score; int *problemnums; int num; public: ~Student(){ delete []score; delete []problemnums; } public: void setname(string na) { name = na; } string getname()const { return name; } void setnum(int n) { num = n; score = new double [num+1]; problemnums = new int[num+1]; for(int i = 0; i < num; i++) { score[i] = 0; problemnums[i] = 0; } } void setscore(int n, int num_max) { score = 100 * ((double) problemnums ) / num_max; } double getscore(int n)const { return score ; } void setproblemnums(int n, int nu) { problemnums = nu; } double gettotalscore() const { double sum = 0; for(int i = 0; i < num; i++) sum+=score[i]; return sum / num; } }; Student &cmpname(Student *stu,string name,int n) { for(int i = 0; i < n; i++) if(stu[i].getname() == name) return stu[i]; } int main() { int n, m; string name; int nums; Student *stu; cin >> n; stu = new Student[n+1]; for(int i = 0; i < n; i++) { cin >> name; stu[i].setname(name); } cin >> m; for(int i = 0; i < n; i++) stu[i].setnum(m); for(int i = 0; i < m; i++) { int k, num_max; cin >> k; for(int j = 0; j < k; j++) { cin >> name >> nums; cmpname(stu, name, n).setproblemnums(i,nums); if(j == 0) num_max = nums; if(num_max < nums) num_max = nums; } for(int j = 0; j < n; j++) stu[j].setscore(i, num_max); } cout << setiosflags(ios::left) << setw(12) << "NAME"; for(int i = 0; i < m; i++) { cout << "TEST" << setiosflags(ios::left) << setw(3)<< i + 1; } cout << "FINAL" << endl; for(int i = 0; i < n; i++) { cout << setiosflags(ios::left) << setw(12) << stu[i].getname(); for(int j = 0; j < m; j++) cout << setiosflags(ios::left) << setw(7) << setprecision(2) << fixed << stu[i].getscore(j); cout << setiosflags(ios::left) << setw(6) << setprecision(2) << fixed << stu[i].gettotalscore() << endl; } delete []stu; }
相关文章推荐
- Problem F: 来算一下自己的成绩吧!
- 测试一下自己在面试中的成绩[zz]
- Problem : 来算一下自己的成绩吧!
- Problem F: 来算一下自己的成绩吧!
- 分享一下自己的成绩
- 王叁寿,令人佩服,激励一下自己
- 整理一下 jQuery 1.4.2 自己常用的部分
- 自己实现单向链表讨论一下LinkedList的效率
- [书籍推荐]为了自己的钱包,为了自己的时间——分享一下自己的淘书经验
- 自己在网上看到的,觉得很好,收藏一下
- 分享一下自己写的一个vscode-leetcode插件
- 最近用360浏览器访问自己的网站,发现都是被优先选用兼容模式打开,这使得网站很难看。为了让360浏览器打开网站的时候优先试用极速模式,找了一下官方论坛,发现了解决方案。
- 【再见久邦】总结一下自己从校招到离职的经历
- 面试自己写的技能,http与https(内容整理一下)
- 用自己的csdn比较了一下Google和百度的搜索
- 从今天起记录一下自己看过的书
- 记录一下自己遇到的问题
- 自己写了一个Asp.net探针的源码,希望大家讨论一下
- 给自己科普一下SOA、AOP、ORM