kgu2683   3년 전

#include <iostream>

#include <string>

using namespace std;

int main()

{

int arr[26] = { 0, };

int max = 0, idx = 0, cnt = 0;

string str;

cin >> str;

for (int i = 0; i < str.length(); i++)

{

str[i] = toupper(str[i]);

arr[str.find(str[i])]++;

}

for (int i = 0; i < sizeof(arr) / sizeof(int); i++)

{

if (max < arr[i])

{

max = arr[i];

idx = i;

}

}

for (int i = 0; i < sizeof(arr) / sizeof(int); i++)

{

if (idx != i && arr[idx] == arr[i])

cnt++;

}

if (cnt != 0)

{

cout << "?\n";

}

else

{

cout << arr[idx] << endl;

}

return 0;

}

댓글을 작성하려면 로그인해야 합니다.