#include "stdio.h"
int main()
{int i,n=0,st=1;
char s[200];
gets(s);
for(i=0;s[i];i++)
if(s[i]>='A'&&s[i]<='Z'||s[i]>='a'&&s[i]<='z')
{
st=1;
printf("%c",s[i]);
}
else
{
if(st==1){printf("\n");n++;}
st=0;
}
printf("\nTotal has %d words.\n",n);
getch();
return 0;
}
#include
#include
int main(void)
{
char shou[1000];
char show[1000][1000];
char *p = NULL;
char *q = NULL;
int i = 0;
int j;
printf("请输入字符串shou:");
gets(shou);
p = q = shou;
while(*p == ' ')
{
p++;
}
q = p;
while(p = strchr(p,' '))
{
strncpy(show[i],q,p-q);
show[i][p-q] = '\0';
while(*p == ' ')
{
p++;
}
q = p;
i ++;
}
if (p == NULL && *q != '\0')
{
strncpy(show[i],q,strlen(q));
show[i][strlen(q)] = '\0';
i++;
}
for(j = 0; j < i; j++)
{
puts(show[j]);
}
printf("单词的个数为%d个\n",j);
}