프로그래머스 - 문자열 내 p와 y의 개수

108번뇌·2020년 10월 1일
0
post-thumbnail

#include <string>
#include <iostream>
using namespace std;

bool solution(string s)
{
    int CountP = 0;
    int CountY = 0;
    int size = s.size();
    bool answer = true;

    for(int i=0; i<size; i++)
    {
        if(s[i]=='p' || s[i]=='P')
        {CountP++;}
        if(s[i]=='y' || s[i]=='Y')
        {CountY++;}
    }
     if(CountP==CountY)
        {
            return true;
        }
        else if(CountP==0 && CountY==0)
        {
            return true;
        }
        else{return false;}
}

내용무.

profile
내일 아침 눈을 떳을 때, '기대되는 오늘 하루를 만들기 위해' 나는 오늘도 생각하고 고민한다.

0개의 댓글