개발 로그/알고리즘
프로그래머스) 문자열 내 p와 y의 개수 c++
CyberSoak
2021. 9. 3. 09:38
#include <string>
#include <iostream>
#include <cctype>
using namespace std;
bool solution(string s)
{
bool answer = true;
int count =0;
for(int i =0; i<s.size(); i++){
if(tolower(s[i])=='p') count++;
else if(tolower(s[i])=='y')count--;
}
if(count) answer = false;
return answer;
}