프로그래머스 레벨 1 테스트

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <string>
#include <iostream>
using namespace std;
 
bool solution(string s)
{
    int p = 0;
    int y = 0;
 
    for(int i = 0 ; i < s.length() ; i++)
    {
        string strTmp;
        strTmp = s[i];
        if(strTmp.compare("p"== 0 || strTmp.compare("P"== 0)
            p++;
        else if(strTmp.compare("y"== 0 || strTmp.compare("Y"== 0)
            y++;
    }
    
    return (p == y) ? true : false;
}
 

 

+ Recent posts