Rohyoohyun / C

0 stars 0 forks source link

1157 단어의 개수 #47

Open Rohyoohyun opened 4 weeks ago

Rohyoohyun commented 4 weeks ago
#include <stdio.h>
#include <string.h>

int main(){
    int cnt=0;
    char str[1000001] ={0};

    gets(str); // 입력
    int len = strlen(str); // 문자열 길이 확인

    if (len == 1 && str[0] == ' '){
        printf("%d", cnt);
        return 0;
    }

    for(int i=1; i<len-1; i++)
        if(str[i] == ' ') cnt++;

    printf("%d", cnt+1);

    return 0;
}