풀스택 개발자 2020. 8. 26. 23:01
#include<iostream>
#include<vector>
using namespace std;

int main()
{
	char number[9] = {'1','2','3','4','5','6','7','8','9'};
	char arr[100];
	int result[10] = {0};
	int max=0;
	int temp = 0;
	cin >> arr;

	for (int i=0; i < 100; i++)
	{
		for (int j = 0; j < 9; j++)
		{
			if (arr[i] == number[j])
			{
				result[j + 1]++;
			}
		}
	}
	for (int i = 1; i <= 9;i++)
	{
		if (result[i] > max)
		{
			max = result[i];
			temp = i;
		}
		else if (result[i] == max)
		{
			if (temp < i)
			{
				temp = i;
			}
		}
	}
	cout << temp;

}