Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 |
Tags
- c++
- TOPCIT 문제 유형
- 백준 10799번 c++
- 유니티
- 백준 2193번 c++
- 코드
- bfs
- 배열 stack overflow
- 풀이
- 백준 17299번 c++
- rigidbody.position
- 프로그래머스 단체사진 찍기 C++
- 백준 10844번 c++
- TOPCIT 후기
- long int 의 차이
- 플레이어 이동
- 백준 11726번 C++
- rigidbody.Moveposition
- 1699번
- 로블록스 script local script 차이
- 유니티 꿀팁
- 프로그래머스 가장 큰 수 C++
- 유니티 LTS
- 백준
- UML Diagram 정리
- 유니티 Rigidbody 이동
- 차이
- transform.position
- 2644번
- 백준 2225번 c++
Archives
- Today
- Total
Kiki Devlog
[1157번][브1] 단어 공부 본문
728x90
1. 모든 알파벳을 대문자로 만들기
2. 크기가 26인 배열을 만들어 A~Z까지 갯수를 세기(countAry[0] 은 A의 갯수 등)
3. 지금까지 제일 많이 등장한 알파벳이라면, answer = 그 알파벳
이전의 알파벳과 동일한 횟수로 많이 등장했다면, answer = '?'
대문자로 만드는 toupper()이나 +=32하는 법만 안다면 쉬운 문제
#include <iostream>
#include <string>
using namespace std;
int main() {
int countAry[26] = { 0 };
int maxAlphabet = -1;
char answer;
string input;
cin >> input;
/*알파벳 대문자 변환 후 숫자 세기*/
for (int i = 0; i < input.length(); i++) {
if (input[i] >= 'a' && input[i] <= 'z') {
input[i] = toupper(input[i]); // input[i] += 32
}
int ascii = input[i] - 'A';
countAry[ascii]++;
}
for (int j = 0; j < sizeof(countAry) / sizeof(int); j++) {
if (countAry[j] > maxAlphabet) { //최대 알파벳이 있다면
maxAlphabet = countAry[j];
answer = 'A' + j;
}
else if (countAry[j] == maxAlphabet) {//최대 알파벳이 중복이라면
answer = '?';
}
}
cout << answer << endl;
return 0;
}
+ 브론즈 1됐다! 오늘 문제를 세개 풀었다. 오버워치 점수는 제자린데,, 그냥 게임말고 이거 하는게 행복할거같다. 내일은 약속있으니까 모레쯤이면 실버가 돼있을까? 맘은 벌써 골드가고싶음(❁´◡`❁)
'Coding Test > 백준' 카테고리의 다른 글
[10872번][브3] 팩토리얼 (재귀함수) (0) | 2022.03.04 |
---|---|
[2869번] 달팽이는 올라가고 싶다 (0) | 2022.03.03 |
[1316번] 그룹 단어 체커 (0) | 2022.03.02 |
[2941번][실5] 크로아티아 알파벳 (0) | 2022.03.02 |
[1065번][실4] 한수 ( char to int, int to char) (0) | 2022.02.15 |
Comments