Hi,
I am doing an assignment and I am suppose to insert values inside of an array to another array.
I tried to do some google searches but nothing I can understand came up.
Assigning arrays to each other was my first guess but it did not work out.
This is an example what I am trying to do.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
int d[5]={99,70,85,93,84};
int my_Values[100];
int seen_SoFar;
addScores(d,5)
addScore(82);
addScore(75);
void addScores(int scores[],int size) {
//here I need to insert the values inside d[5] to my_Values[100]
//Also I need to increment or decrement seen_SoFar to tell me how full my_Values is.
}
void addScore(int score) {
//Here I shold be able to add the numbers 82 and 75 to the my_Values[100]
}
Thank you for your reply.
I did not get what size_t pos is suppose to mean.
size_t size_a and b are the size of the int a[] and int b[] but what is pos?
Also I did not want to post the whole program, but my_Values[100] is inside a class and this addScores function is also in the class.
Do I still have to pass the my_Values to the funciton?
Header
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
class Grader {
public:
Grader( );
Grader(int seen);
void addScore( int score );
void addScores( int scores[], int size );
void clear();
int findBiggest() const;
int findSmallest( ) const;
int my_Values[ MAXSIZE ];
int my_valuesSeenSoFar;
};
Grader.cpp
1 2 3 4
void Grader::addScores( int scores[], int size ){
}
and the main
1 2 3 4 5 6 7 8 9 10 11 12 13 14
Grader g;
int d[5]= {99,70,85,93,84};
int 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( );
So here is the code, I did not get why you passed so many variables and what are they doing.