#include<stdio.h>
#include<string.h>
void fun(int length, char *a);
int main()
{
char a[100];
int length;
printf("请输入一组字符串\n");
gets(a);
length=strlen(a);
fun(length, a);
}
void fun(int length, char *a)
{
int i, count1, count3, count4, count5, count6;
count1 = count3 = count4 = count5 = count6 = 0;
for(i = 0; i < length; i++)
{
if(a[i] == ' ')
count1++;
else if(a[i] <= 'z' && a[i] >= 'a')
count3++;
else if(a[i] <= 'Z' && a[i] >= 'A')
count4++;
else if(a[i] <= '9' && a[i] >= '0')
count5++;
else
count6++;
}
printf("单词的个数为%d\n", count1+1);
本内容试读结束,登录后可阅读更多
下载后可阅读完整内容,剩余2页未读,立即下载