怎么输入三行单词?
#include <stdio.h>int main()
{int kongge=0,danchi=0,i,j=0,m,n=0,x,y=0,kongge1=0,danchi1=0,kongge2=0,danchi2=0,kongge3=0,danchi3=0;
char a[200];
char b[200];
char c[200];
char d;
char e;
char f;
int w;
while(1)
{printf("请选择你需要的选项:\n");
printf("\t\t1、执行操作:\n");
printf("\t\t2、输出空格数和单词数:\n");
printf("\t\t3、退出系统:\n");
scanf("%d",&w);
if(w==3)
break;
switch(w)
{
case 1:
printf("请输入三行字母:");
gets(a);
gets(b);
gets(c);
for(i=0;(d=a[i])!='\0';i++)
{
if(d==' ')
{
kongge1++;
j=0;
}
else if(j==0)
{
danchi1++;
j=1;
}
}
for(m=0;(e=b[m])!='\0';m++)
{
if(e==' ')
{
kongge2++;
n=0;
}
else if(n==0)
{danchi2++;
n=1;
}
}
for(x=0;(f=c[x])!='\0';x++)
{
if(f==' ')
{
kongge3++;
y=0;
}
else if(y==0)
{danchi3++;
y=1;
}
}
kongge=kongge1+kongge2+kongge3;
danchi=danchi1+danchi2+danchi3;
printf("空格数为:%d\n",kongge);
printf("单词数为:%d\n",danchi);
break;
case 2:printf("空格数:%d\n单词数:%d\n",kongge,danchi);break;
}
}
return 0;
}