Enter No. of candidates :3
Enter Name of candidate 1:obama
Enter Name of candidate 2:bush
Enter Name of candidate 3:clinton
Enter No. of Precinct(s) :3
Precinct1 Precinct2 Precinct3 Total
1. Obama 100 203 504 807
2. Bush 600 900 10 1510
3. Clinton 567 123 90 780
Bush Won with 1510 votes
You're not dumb for not knowing stuff mate, especially if you haven't been taught it.
I havent got time to change it this evening sorry, but try and follow the logic and replace the vectors with arrays.
#include <iostream>
#include <ctime>
#include <string>
#include <conio.h>
usingnamespace std;
int numcand;
int numprct;
int row, col;
char candname [5][20];
int table[10][10];
int total[10];
int main ()
{
system("COLOR 09");
//******************************************************************
//******************************************************************
//*********************GETTING THOSE INPUTS NEEDED******************
//******************************************************************
//******************************************************************
//Accepts Number of Candidates
cout<<"\nEnter number of Candidates for the Election [1-10]: ";
cin>>numcand;
cin.ignore();
//Test if no. of candidates is <10 && >1
while ((numcand<1 && numcand!=0) || numcand>10)
{
system("cls");
cout<<"\nPlease just enter form 1-10";
cout<<"\nEnter number of Candidates for the Election [1-10]: ";
cin>>numcand;
system("cls");
}
if (numcand == 0)
{
cout<<"\nNo Voting Will Happen!"<<endl;
return 0;
}
//Accepts the Name of the Candidates
for (int ctr=1; ctr<=numcand; ctr++)
{
cout<<"\nEnter the Name of Candidate Number "<<ctr<<" : ";
cin.getline(candname[ctr],20);
}
//Accepts Number of Precincts
cout<<"\nPlease enter number of precincts : ";
cin>>numprct;
system("cls");
//******************************************************************
//******************************************************************
//**********************PROCESS FOR OUTPUT**************************
//******************************************************************
//******************************************************************
srand(time(NULL));
//Display Precinct Nos
cout<<"\t\t";
for (ctr=1; ctr<=numprct; ctr ++)
{
cout<<"\tP"<<ctr<<"";
}
//Display Name of Candidates
for (ctr=1; ctr<=numcand; ctr++)
{
cout<<"\n\n"<<candname[ctr];
//Display Random Numbers
cout<<"\t";
for (row=0; row<1; row++)
{
for (col=0; col<numprct; col++)
{
table[row][col] = rand()%999;
cout<<"\t"<<table[row][col];
}
cout<<"\n\n";
}
}
for (row=0; row<numcand; row++)
{
total[row] = 0;
for (col=0; col<numprct; col++)
{
total[row] += table[row][col];
}
}
for(row=0; row<numcand; row++)
{
cout<< "\nTotal Votes for Candidacy of " <<(candname[row+1])<<" : " << total[row];
}
getch();
return 0;
}