[구름]단어의 개수 세기

YongJun·2024년 12월 14일

[코딩테스트]

목록 보기
9/22

단어의 개수 세기

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

int main() { 
	int count = 0; 
	int length, i=0; 
	char str[1001];
    
	gets(str); 
	while(1){ 
		if(str[i]==0) break; 
		else if((str[i] != 32) &&((str[i+1]==32)||(str[i+1] ==0))) count++; //32는 공백, 0은 엔터 
		i++; 
	} 
	printf("%d", count);
    
	return 0; 
}
profile
Student

0개의 댓글