Notice
Recent Posts
Recent Comments
«   2025/07   »
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31
Tags more
Archives
Today
Total
관리 메뉴

Share Garam's everyday life.

문자열 다루기 기본 본문

알고리즘

문자열 다루기 기본

가람스나이퍼님 (Joshua_Choi_Brother) 2021. 4. 22. 21:12

#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>

// 파라미터로 주어지는 문자열은 const로 주어집니다. 변경하려면 문자열을 복사해서 사용하세요.
bool solution(const char* s) {
    bool answer = true;
    int count=0;
    int i=0;
    
    while(s[i++])
        count++;
    i=0;
    if(count==4||count==6){
        while(s[i]){
            if(s[i]<48||s[i]>57){
                answer=false;
                break;
            }
            i++;
        }
    }
    else
        answer=false;    
    return answer;
}

'알고리즘' 카테고리의 다른 글

문자열을 정수로 바꾸기  (0) 2021.04.22
수박수박?  (0) 2021.04.22
문자열 내림차순으로 배치하기  (0) 2021.04.22
두 정수 사이의 합  (0) 2021.04.22
음양 더하기  (0) 2021.04.21