Q

백준 1152

백준 1152번 문제


C code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <stdio.h>
#include <string.h>

int main(void)
{
char s[1000000] = "";
int count = 0;
char * ptr = NULL;

// \n 문자가 나오기 전까지 모든 입력을 받는다.
scanf("%[^\n]s", s);

ptr = strtok(s, " ");
while(ptr != NULL)
{
ptr = strtok(NULL, " ");
count++;
}

printf("%d\n", count);

return 0;
}