Advertisement
Guest User

Untitled

a guest
Nov 13th, 2019
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.62 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.  int N;
  8.  int M;
  9.  int Votes;
  10.  cin >> N;
  11.  cin >> M;
  12.  cin >> Votes;
  13.  int CandidatesList[1000] = {0};
  14.     for (int i = 0; i < M; i++)
  15.     {
  16.         for (int j = 0; j < N-1; j++)
  17.         {
  18.  
  19.             if((Votes - 1) == j)
  20.                 CandidatesList[j] += 1;
  21.         }
  22.     }
  23.  int MaxVotes = 0;
  24.     for (int i = 0; i < N-1; i++)
  25.     {
  26.         if (CandidatesList[i] > MaxVotes)
  27.                 MaxVotes += CandidatesList[i];
  28.     }
  29. for (int i = 0; i < N-1; i++)
  30.     {
  31.     if ((CandidatesList[i]) == MaxVotes)
  32.         cout << i + 1 << " " ;
  33.     }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement