-
Increasing vector
Hey, guys. Here's my inquiry: I have a matrix of votes (Candidates x Precincts),
and I need to both calculate the totals for each candidate and the total
votes overall (I think the latter is easier).
Here's my code of the function I'm supposed to add 1 line for each duty I
need to do:
//------------------------------------------------
void LoadAPrecinct(ResultsType &R)
/* Prompts user to choose a precinct, and then prompts for and
stores votes for each candidate for that precinct
Post: Votes entered for a precinct */
{
int UserPct;
cout << "\nWhat precinct? " ;
cin >> UserPct;
int PctNum = UserPct - 1;
for (int CNum = 0; CNum < R.NumCandidates; CNum++) {
cout << "\nEnter votes for this precinct for " << R.Candidates[CNum] <<
": ";
cin >> R.Votes[CNum][PctNum];
R.CandTotals[PctNum] += R.Votes[CNum][PctNum]; // Adding Candidate
Votes
R.TotalVotes += R.CandTotals[PctNum]; // Accumulating Total Votes
}
} // end LoadAPrecinct
Thanks a lot
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks