我真的很想解决这个问题。
如果有人能把我推向正确的方向。我将不胜感激
以下是我的代码
分级机.h
#ifndef GRADER_H
#define GRADER_H
#define MAXSIZE 100
#include <iostream>
#include <cstdlib>
class Grader {
public:
Grader( );
void addScore( int score );
void addScores( int scores[], int size );
void clear();
int findBiggest( ) const;
int findSmallest( ) const;
private:
int my_Values[ MAXSIZE ];
int my_ValuesSeenSoFar;
};
#endif
分级机.cpp
#include <iostream>
#define MAXSIZE 100
#include "Grader.h"
Grader::Grader( ){
my_Values [MAXSIZE] = 0;
my_ValuesSeenSoFar = 0;
}
void Grader::addScore( int score ){
my_Values[MAXSIZE] = score;
}
void Grader::addScores( int scores[], int size ){
my_Values[MAXSIZE] = scores[size];
}
void Grader::clear(){
my_Values[0];
}
int Grader::findBiggest() const{
int i;
for (i = 0; i < MAXSIZE; i++)
return my_Values[i];
}
int Grader::findSmallest( ) const{
}
驱动程序.cpp
#include <iostream>
#include "Grader.h"
using namespace std;
int main( )
{
Grader g;
double d[5]= {99,70,85,93,84};
double e[4]= {100,81,60,91};
g.addScore( 75 );
g.addScore( 82);
g.addScores( d, 5 );
cout << "Best Score = " << g.findBiggest( ) << endl;
/// should give value 99
cout << "Worst Score = " << g.findSmallest( ) << endl;
/// should give value 70
g.clear( );
g.addScore( 50 );
g.addScore( 74 );
g.addScores( e, 4 );
cout << "Best Score = " << g.findBiggest( ) << endl;
/// should give value 100
cout << "Worst Score = " << g.findSmallest( ) << endl;
/// should give value 50
}
我无法弄清楚 a) 如何准确地实现 addScore/addScores
b) 如何将这些分数称为 findBiggest 和 findSmallest。