|
|
|
|
|
|
|
cin.get(name[candidate], 11); // At most 10 chars plus \0
cin.ignore(100, \n);
}
}
//******************************************************************
void ZeroVotes( /* out */ VoteTable votes ) // Array of vote totals
// Zeroes out the votes array
// Postcondition:
// All votes[0..NUM_PRECINCTS-1][0..NUM_CANDIDATES-1] == 0
{
int precinct; // Loop counter
int candidate; // Loop counter
for (precinct = 0; precinct < NUM_PRECINCTS; precinct++)
// Invariant (prior to test):
// votes[0..precinct-1][0..NUM_CANDIDATES-1] == 0
// && 0 <= precinct <= NUM_PRECINCTS
for (candidate = 0; candidate < NUM_CANDIDATES; candidate++)
// Invariant (prior to test):
// votes[precinct][0..candidate-1] == 0
// && 0 <= candidate <= NUM_CANDIDATES
votes[precinct][candidate] = 0;
}
//******************************************************************
void WriteTable(
/* in */ const VoteTable votes, // Total votes
/* in */ const String10 name[], // Candidate names
/* inout */ ofstream& reportFile ) // Output file
// Writes the vote totals in tabular form to the report file
// Precondition:
// votes[0..NUM_PRECINCTS-1][0..NUM_CANDIDATES] are assigned
// && name[0..NUM_CANDIDATES-1] are assigned
// Postcondition:
// The name array has been output across one line, followed by
// the votes array, one row per line
|
|
|
|
|
|