Create 1226.c

This commit is contained in:
KiritoTRw 2016-04-28 08:57:25 +08:00
parent 8784cc2469
commit ab1804f3b8

26
QUSTOJ/1226.c Normal file
View File

@ -0,0 +1,26 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
char cmdline[10240];
int main()
{
int line,word;
scanf("%d%*c",&line);
for(;line>0;line--)
{
memset(cmdline,0,10240);
gets(cmdline);
int i;
int len=strlen(cmdline);
word=0;
for(i=1;i<len-1;i++)
{
if(cmdline[i]==' '&&cmdline[i-1]!=' '&&cmdline[i+1]!=' ')
{
word++;
}
}
printf("%d\n",++word);
}
return 0;
}