平均最低最高等级计算机
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了平均最低最高等级计算机相关的知识,希望对你有一定的参考价值。
#include <cstdlib> #include <iostream> #include "firstQuiz.h" using namespace std; static int studentNo = 1; static int zeroInput = 0; firstQuiz::firstQuiz(int i) { errorC = i; } void firstQuiz::errorHandling() { //static int errorC; //we can use this instead of interface solution //if there is an error, show the error message if (errorC == 1) cout << "error: try again: "; //no problem else cout << "enter the negative number tolerance quantity: "; cin >> zeroInput; if (zeroInput < 0) { errorC = 1; //error logger errorHandling(); //recursion } } //if we don't want to write cout's again and again, we creat a function void firstQuiz::pointInput() { cout << "please enter the grade for student " << studentNo++ << " : "; cin >> point; } //"everything is something happen" (sinyor terim) void firstQuiz::compute() { int zeroCount = 0; char closer; counterA = 0; avarageA = 0; maximumA = 0; minimumA = 100; counterB = 0; avarageB = 0; maximumB = 0; minimumB = 100; //classic do-while structure do{ pointInput(); //when entered grade is negative and error handler is activated while(point<0 && zeroCount != zeroInput) { zeroCount++; cout << "negative! want to quit? (y / n) : "; cin >> closer; if (closer == 'y' || closer == 'Y') { break; } if( closer == 'n' || closer == 'N') { pointInput(); } } //for above 50 if(point>50) { counterA++; avarageA+=point; if(point > maximumA) maximumA=point; if(point < minimumA) minimumA=point; } //for belove 50 if(point<=50) { //if it is negative, easily ignore that! if(point<0) break; counterB++; avarageB+=point; if(point > maximumB) maximumB=point; if(point < minimumB) minimumB=point; } }while(point>=0); } //compute avarages seperately void firstQuiz::computeAvarage() { avarageA = avarageA / counterA; //for above 50 avarageB = avarageB / counterB; //for belove 50 } //result outputs void firstQuiz::printResult() { //+50 cout << endl << "maximum (+ 50) is " << maximumA << endl; cout << "minimum (+ 50) is " << minimumA << endl; cout << "avarage (+ 50) is " << avarageA << endl << endl; //-50 cout << "maximum (- 50) is " << maximumB << endl; cout << "minimum (- 50) is " << minimumB << endl; cout << "avarage (- 50) is " << avarageB << endl << endl; }
以上是关于平均最低最高等级计算机的主要内容,如果未能解决你的问题,请参考以下文章
如何在 TSQL 中排除 1800 万条记录的最高和最低 5% 的年薪,然后使用所选数据计算平均值