#include "stdio.h"
#define N 30
void main()
{
char i[N];
int j;
int words,spaces,numbers,others;
words=spaces=numbers=others=0;//下面要自加的变量一定要初始化为0
printf("please input the passage.\n");
gets(i);
//for(j=0;j<30;j++)
for(j=0;j<N&&i[j]!='\0';j++)
{
//if(i[j]==' ')
//是两个等号,不是一个等号
if(i[j]==' ')
spaces++;
//else if(i[j]>='A'&&i[j]<='Z'||i[j]>='a'&&i[j]<='z')//&& 和 || 之间要加括号:(...&&...)||(...&&...)
else if((i[j]>='A'&&i[j]<='Z')||(i[j]>='a'&&i[j]<='z'))
words++;
else if(i[j]>='0'&&i[j]<='9')
numbers++;
else
others++;
}
printf("the words are:%d\n",words);
printf("the spaces are:%d\n",spaces);
printf("the others are:%d\n",others);
printf("the numbers are:%d\n",numbers);
}