#include <string> #include <iostream> using namespace std; bool solution(string s) { int pCnt = 0; int yCnt = 0; for(int i = 0; i < s.size(); i++) { if(s[i] == 'P' || s[i] == 'p') { pCnt++; } else if(s[i] == 'Y' || s[i] == 'y') { yCnt++; } } if(pCnt == yCnt) { return true; } else { return false; } } | cs |
'Programmers > Level 1' 카테고리의 다른 글
[프로그래머스 1] 문자열 다루기 기본 (C/C++) (0) | 2019.10.17 |
---|---|
[프로그래머스 1] 문자열 내림차순으로 배치하기 (C/C++) (0) | 2019.10.17 |
[프로그래머스 1] 문자열 내 마음대로 정렬하기 (C/C++) (0) | 2019.10.17 |
[프로그래머스 1] 두 정수 사이의 합 (C/C++) (0) | 2019.10.17 |
[프로그래머스 1] 나누어 떨어지는 숫자 배열 (C/C++) (0) | 2019.10.17 |