operand1=res; op=getchar(); }
printf(\ return 0; }
8. 统计一行文本的单词个数:输入一行字符,统计其中单词的个数。各单词之间用空格分隔,空格数可以是多个,试编写相应程序。 解答:
#include
char op; int count,word;
printf(\ op=getchar(); count=word=0; while(op!='\\n'){ if(op==' ') word=0;
else if(word==0){ count++; word=1; }
op=getchar(); }
printf(\ return 0; }