// 单词.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
#include "stdio.h"
void main()
{
char string[81];
int i,num=0,word=0;
char c;
gets(string);
for (i=0;(c=string[i])!='\0';i++) {
if (c==' ') word=0;
else if (word==0) {
word=1;
num++;
}
}
printf("this are num=%d words.\n",num);
}
//
#include "stdafx.h"
#include "stdio.h"
void main()
{
char string[81];
int i,num=0,word=0;
char c;
gets(string);
for (i=0;(c=string[i])!='\0';i++) {
if (c==' ') word=0;
else if (word==0) {
word=1;
num++;
}
}
printf("this are num=%d words.\n",num);
}