본문 바로가기
Problem-solving/프로그래머스

프로그래머스 - 문자열 다루기 기본 (C++)

by taehee.kim.dev 2020. 3. 5.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include <string>
 
using namespace std;
 
bool solution(string s) {
 
    if(!(s.length() == 4 || s.length() == 6))
        return false;
    
    for(int i = 0; i < s.length(); i ++){
        if(!('0' <= s[i] && s[i] <= '9'))
            return false;
    }
 
    return true;
}
cs

댓글