공백 / 문자 판별

- 해당 문제는 숫자인지 판별하는 문제이며 <cctype>의isdigit()을 사용해 판별함
- 공백인지 판별하기 위해서는 역시 <cctype>의isspace()를 사용한다
- 추가로, 내가 받은 문자열이 숫자인지 / 문자들만 있는지 확인하기 위해 atoi()를 사용하면 된다
    string s1 = "대한민국";
    string s2 = "-123";
    string s3 = "456";
    string s4 = "0";
    
    cout << atoi(s1.c_str()) << endl; 
    cout << atoi(s2.c_str()) << endl; 
    cout << atoi(s3.c_str()) << endl; 
    
    cout << atoi(s4.c_str()) << endl; 
    cout << (atoi(s4.c_str()) != 0 || s4.compare("0") == 0) << endl; 
코드
#include <string>
#include <vector>
#include <cctype>
using namespace std;
bool solution(string s) {
    if(s.length() != 4 && s.length() != 6) return false;
    for(auto a : s){
      
        if(!isdigit(a)) return false;
    }
    return true;
}