Submission #1232315


Source Code Expand

#include <iostream>
#include <cstring>

using namespace std;

int main(){
	int N,sum[50],max_votes = 0;
	string S[50];

  cin>>N;

	for (int i = 0; i < N; i++) {
		cin>>S[i];
		sum[i] = 0;
		for (int j = 0; j < i; j++) {
			if (S[i] == S[j]) {
				sum[j]++;
				break;
			}
		}
	}

	for (int i = 0; i < N; i++) {
		if (sum[i] > max_votes) {
			max_votes = sum[i];
			x = i;
		}

	}

	cout<<S[x]<<endl;

  return 0;
}

Submission Info

Submission Time
Task B - 投票
User Cmer
Language C++14 (GCC 5.4.1)
Score 0
Code Size 451 Byte
Status CE

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:26:4: error: ‘x’ was not declared in this scope
    x = i;
    ^
./Main.cpp:31:10: error: ‘x’ was not declared in this scope
  cout<<S[x]<<endl;
          ^