Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
H2O題#include <stdio.h> #include <string.h> #include <iostream> #include <cstdlib> #include <string> #include <vector> #include <map> #include <cmath> using namespace std; double ave, sd; int gpa(double scr){ if(scr >= ave+sd) return 4; if(scr >= ave) return 3; if(scr >= ave-sd) return 2; return 1; } int main(int argc, char **argv){ cout << "MAKING THE GRADE OUTPUT" << endl; int n; cin >> n; while(n--){ int stu, tes, adjTes; cin >> stu >> tes; if(tes <= 2) adjTes = tes; else adjTes = tes-1; double scr[100]; int bon[100], abc[100]; for(int i = 0; i < stu; i++){ int sum = 0, mn = 101; for(int j = 0; j < tes; j++){ int tmp; cin >> tmp; sum += tmp; if(tmp < mn) mn = tmp; } if(tes > 2) sum -= mn; scr[i] = sum * 1.0 / adjTes; cin >> bon[i] >> abc[i]; } ave = 0, sd = 0; for(int i = 0; i < stu; i++) ave += scr[i]; ave /= stu; for(int i = 0; i < stu; i++) sd += (scr[i]-ave)*(scr[i]-ave); sd = sqrt(sd/stu); if(sd < 1) sd = 1; double avp = 0; for(int i = 0; i < stu; i++){ double fin = scr[i] + 3 * (bon[i]/2); int pnt = gpa(fin); pnt -= abc[i]/4; if(!abc[i]) pnt++; if(pnt>4) pnt=4; if(pnt<0) pnt=0; avp += pnt; } avp /= stu; printf("%.1lf\n", avp); } cout << "END OF OUTPUT" << endl; return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator