cout << 'a' + 1; 할 경우 , 정수가 출력됨. 왜냐하면 cout 오른쪽에서 정수 계산 처리후 출력됨.
'b' 가 나오게 하려면
char c = 'a';
cout << a + 1;
-> 이렇게 하면 b가 출력됨.
: 입력으로 들어오는 string의 앞 문자만 보고 카운팅을 진행함.
알파벳 소문자 이므로 , 배열 26개 만들어 놓고, 카운팅함.
#include <stdio.h>
#include <iostream>
#include <string>
using namespace std;
#include <algorithm>
#include <vector>
#include <deque>
int main()
{
// 코드 최적화
// 1. 유니폼 초기화로 진행함.
int n{0};
cin >> n;
int arr[26]{0,};
//a는 arr의 0번째 인덱스로
// 전위 증감자로 진행함. 후위 증감자는 임시객체를 생성하므로. 후위 안해
for (int i = 0; i < n; ++i)
{
string name;
cin >> name;
char word = name[0];
arr[word - 'a']++;
}
string result{ "" };
for (int i = 0; i < 26; i++)
{
if (arr[i] >= 5)
result += 'a' + i;
}
if (result == "")
cout << "PREDAJA";
else
cout << result;
}