第1个回答 2011-03-20
/*C*/
#include <stdio.h>
int main()
{
char string[81];
int i;
int num = 0; /* 统计单词个数 */
int 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("\nThere are %d words int the line.\n", num);
return 0;
}
第2个回答 2011-04-01
;
#include <string.h>
#include <stdio.h>
#include <iostream.h>
int main(int argc, char* argv[])
{
char x[1000];
unsigned int i=0 ;
int n=0 ;
char flag=0;
cin.getline(x,255);
strcat(x," ");
for(i=0;i<strlen(x);i++)
{
if(((x[i]>='a')&&(x[i]<='z'))||((x[i]>='A')&&(x[i]<='Z')))
else
{
if (flag==1 ) n++;
flag=0;
}
}
printf("%d\n",n);
getchar();
return 0;
}
另外,站长团上有产品团购,便宜有保证
第3个回答 2011-03-21
#include<iosteam>
using namespace std;
int main()
{
char string[81];
int i;
int num = 0; /* 统计单词个数 */
int 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++;
}
}
cout<<num<<endl;
return 0;
}
第4个回答 2011-03-21
能不能把文字复制到word里呢?
word里的工具栏下有字数的统计呀本回答被提问者采纳