单词数
you are my friend #
4
主要是用到了map把字符串转换成数字处理!
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<map>
#include<string>
using namespace std;
int main()
{
char s1[1110000],s2[10010];
int a,i,j,t,cot,len;
while(gets(s1))
{
if(s1[0]=='#')
break;
cot=0;
map<string,int>q;
q.clear();
len=strlen(s1);
for(i=0;i<len;i++)
{
if(s1[i]==' ')
continue;
else
{
t=0;
for(j=i;s1[j]!=' '&&j<len;j++)
s2[t++]=s1[j];
s2[t]='\0';
if(!q[s2])
{//如果字符串没出现过,就标记
q[s2]=1;
cot++;
}
}
i+=t;
}
printf("%d\n",cot);
}
return 0;
}
1万+



被折叠的 条评论
为什么被折叠?



