#include <bits/stdc++.h>
using
namespace
std;
int
main()
{
int
choice, i, N;
vector<string> candidates
= {
"A"
,
"B"
,
"C"
,
"D"
,
"E"
};
N = candidates.size();
vector<
int
> votes(N);
do
{
cout <<
"\n1. Vote for your "
<<
"favorite Candidate.\n"
;
cout <<
"2. Check the number "
<<
"of votes of each "
"Candidate.\n"
;
cout <<
"3. Check the candidate "
<<
"who is leading.\n"
;
cout <<
"0. Exit\n"
;
cout <<
"Enter Your choice: "
;
cin >> choice;
cout <<
"\n"
;
switch
(choice) {
case
1: {
int
candidatechoice;
for
(i = 0; i < N; i++)
cout << i + 1 <<
"."
<< candidates[i]
<<
"\n"
;
cout <<
"Choose your candidate: "
;
cin >> candidatechoice;
cout <<
"\n"
;
votes[candidatechoice - 1]++;
break
;
}
case
2: {
for
(i = 0; i < N; i++)
cout << i + 1 <<
"."
<< candidates[i] <<
" "
<< votes[i] <<
"\n"
;
break
;
}
case
3: {
int
mx = 0;
string winner;
for
(
int
i = 0; i < N; i++)
if
(votes[i] > mx) {
mx = votes[i];
winner = candidates[i];
}
int
flag = 0;
for
(
int
i = 0; i < N; i
if
(votes[i] == mx
&& winner != candidates[i]) {
flag = 1;
break
;
}
if
(!flag)
cout <<
"The current winner is "
<< winner <<
".\n"
;
else
cout <<
"No clear winner\n"
;
}
default
:
"Select a correct option"
;
}
}
while
(choice != 0);
return
0;
}