void ShowResult(char candidates[][20], int *results)
{
cout<<"\nResults:\n";
for (int i=0;i<N;i++)
{
cout<<i+1<<". "<<candidates[i]<<"\t"<<results[i]<<endl;
}
}
int Max(int *arr)
{
int max=0;
for (int i=1;i<N;i++)
{
if (arr[i]>arr[max])
max = i;
}
return max;
}
int main()
{
char candidates[N][20] = {"FPJ","ROCO","GMA"};
int results[N] = {0};
while(true)
{
ShowMenu(candidates);
cout<<"Your choice: ";
char choice;
cin>>choice;
switch(tolower(choice))
{
case 'q':
cout<<"The winner is "<<candidates[Max(results)]<<"!\n";
return 0;
break;
case 'r':
cout<<"\nTemporary results:\n";
ShowResult(candidates,results);
break;
case 'v':
cout<<"Enter candidate number: ";
int n;
cin>>n;
results[n-1]++;
break;
}
cout<<endl;
}
return 0;
}