这个题目怎么总做不出来啊 求做题步骤 万谢
从键盘输入一行字符(最长不超过80字符),统计其中单词(以空格作为间隔符的字符串)的个数,例如输入How are you,要求输出结果3。
#include <stdio.h> void main() { char c[100]; int i=0; int j=0; printf("请输入一行字符:"); scanf("%d",&c[i]); while((c[i]=getchar())!='\n') {if(c[i]>='a'&&c[i]<='z'||c[i]>='A'&&c[i]<='Z') i++; if(c[i]==' ') j++; } printf("输入的字母数:%d\n",i); printf("空格数:%d\n",j); }