알고리즘/BOJ문제풀이
184번째 문제 - 1371 가장 많은 글자
quantdave
2016. 11. 24. 00:37
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stdio.h>
using namespace std;
int main() {
int C,t;
int ans[26] = { 0 }, max = 0;
string s;
vector<int> input;
while (cin>>s) {
for (int i = 0; i < s.length(); i++)
{
ans[s[i] - 'a']++;
}
s = "";
}
for (int i = 0; i < 26; i++)
{
if (max < ans[i])max = ans[i];
}
for (int i = 0; i < 26; i++) {
if (ans[i] == max)cout << (char)('a' + i);
}
}
뭐 별거 있나 ... 문제 이름 그대로 글자수만 세면 됨