Answered You can hire a professional tutor to get the answer.

QUESTION

The main function is elect_candidate which has most of the brain of this program.

The main function is elect_candidate which has most of the brain of this program. Towards to bottom of it when i run it gives me errors for the lines where i compare ballots with -1 and set the values to 0

; *FILENAME = ; MAXBALLOTS = ; NUM_CANDIDATES = ; ballots[MAXBALLOTS][NUM_CANDIDATES], numBallots) { winner = ; round=; tally[NUM_CANDIDATES + ] = { }; percentages[NUM_CANDIDATES + ]; neg = ;(winner==){<<<<round<<<<;( i = ;i<numBallots;i++){ choice;( rank=;rank<;rank++){choice=ballots[i][rank];(tally[choice]==){tally[choice]+=;}{tally[choice]++;;}}round++;} << << ; ( i = ; i < NUM_CANDIDATES + ; i++) {percentages[i] = ()tally[i] / numBallots; << fixed << setprecision(); << << i << << percentages[i]; << ;}( i=;i<NUM_CANDIDATES+ ;i++){(percentages[i]>)winner==i;}(winner==){ lowestPercent=percentages[]; lowestCandidate=;( i=;i<NUM_CANDIDATES+ ;i++){(percentages[i]<lowestPercent){lowestPercent=percentages[i];lowestCandidate=i;}}ballots[lowestCandidate]== ;( i=;i<NUM_CANDIDATES+ ;i++){(ballots[i]!==)ballots[i]==;}}} ;} {; tmp; nLines; numBallots = ; ballots[MAXBALLOTS][NUM_CANDIDATES]; (getline(f, tmp)) {nLines = atoi(tmp.c_str()); ( i = ; i < nLines; i += ) { << ; ( j = ; j < NUM_CANDIDATES; j++) {getline(f, tmp);ballots[numBallots][j] = atoi(tmp.c_str()); << << ballots[numBallots][j];}numBallots++; << ;} << << numBallots << << ; winner = ; round = ;winner = elect_candidate(ballots,numBallots); << << winner << ;numBallots = ;}system(); ;}
Show more
LEARN MORE EFFECTIVELY AND GET BETTER GRADES!
Ask a Question