1 int Count_word(char *s){
2 int state;
3 if(s[0]==' ') state=0;
4 else state=1;
5 int ans=0;
6 for(int i=1;s[i];i++){
7 if(s[i]==' ') {
8 if(state==1){
9 ans++;
10 state=0;
11 }
12 }
13 else {
14 if(state==0){
15 state=1;
16 }
17 }
18 }
19 if(state==1) ans++;
20 return ans;
21 }