编写一个C语言程序,关于“统计一条英文句子中字母的个数,在主程序中实现输入输出”

2024-12-03 19:02:36
推荐回答(1个)
回答1:

句子【I am your father】有单词4个
。Press any key to continue
#include "stdio.h"
#include "string.h"

int main()
{
int i,j,k=0,len,mark=0,count=0;
char str[]="I am your father";

len = strlen(str);
for (i=0;i {
if (str[i]==' ')
{
mark=1;
count++;
}
}
printf("句子【%s】有单词%d个\n。",str,count+1);
return 0;
}