euisblue
12918. 문자열 다루기 기본

Level 1 문자열 다루기 기본

시간 복잡도: O(N)

1#include <bits/stdc++.h> 2using namespace std; 3 4bool solution(string s) { 5 const int SIZE = s.size(); 6 if(SIZE!=4 && SIZE!=6) return false; 7 for(int i=0; i<SIZE; ++i) 8 if(isalpha(s[i])) return false; 9 return true; 10}

isalpha()함수를 사용하여 문자인지 확인을 했다. 반대로 숫자인지 확인하는 isdigit()함수도 존재한다.