#include <stdio.h>
#include <string.h>

int main() {
    char str[1000001];
    int cnt=0;
    //띄어쓰기 포함 하나의 문자열 입력
    scanf("%[^\n]",str);
    // 첫번째 띄어쓰기 일 경우 -1
    if (str[0]==' ') cnt--;
    // 마지막 띄어쓰기 일 경우 -1
    if (str[strlen(str)-1]==' ') cnt--;
    //문자열 전체 띄어쓰기 갯수 찾음
    for (int i=0; i<strlen(str); i++) {
        if (str[i]==' ') cnt++;
    }
    printf("%d",cnt+1);
    return 0;
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: