Survey program, name repeating, need idea
<p>The first line should consist of N number who would determinate the number of names entered, the program output should display the name who is repeated most of the times, I hope that makes sense.</p>

<p>Example:</p>

<p>4</p>

<p>John</p>

<p>Harry</p>

<p>Davis</p>

<p>Harry</p>

<p>The output would be "Harry". Any idea how I would go with this in C++?</p>

<p>My current code:</p>

<pre><code>    #include &lt;iostream&gt;
using namespace std;
string niza[100];
int index,brojac=0,maxi=0;

int proverka(string ime, int n)
{
    for(int i=0; i&lt;=n-1; i++)
    {
        if(ime==niza[i])
        {
        if(brojac==0)
        {
            index=i;
            brojac++;
            if(brojac&gt;maxi) maxi=brojac;
        }
        else
        {
            brojac=0;
        }
        }
    }
}

int main()
{

int n;
    cin &gt;&gt; n;
    for(int i=0; i&lt;=n-1; i++)
    {
        cin &gt;&gt; niza[i];
    }
    for(int i=0; i&lt;=n-1; i++)
    {
        proverka(niza[i],n);
    }
    cout &lt;&lt; niza[index];
    return 0;
}
</code></pre>
