openjudge 7920 统计单词数

来源:互联网 发布:库里今年季后赛数据 编辑:程序博客网 时间:2024/06/01 08:28

统计单词数

链接

这道题曾经卡死蒻蒟的我

后来才发现这是一道水题

思路

没什么思路这是道水题 把每个单词搞出来对比一下就行

代码

#include <cstdio>#include <cctype>#include <cstring>#include <iostream>#define  Maxn 1000001using namespace std;char str[Maxn],s[Maxn];int k,tot,ans,pos=-1;int main(){gets(str);gets(s);int len1=strlen(str);int len2=strlen(s);for(int i=0;i<len1;i++)str[i]=tolower(str[i]);for(k=0;k<len2;k++){string temp="";while(s[k]!=' '&&k!=len2)temp+=tolower(s[k++]);if(temp==str){if(pos==-1)pos=k-temp.length();ans++;}}(ans==0)?(cout<<-1):(cout<<ans<<' '<<pos);}
欢迎指出Bug


End。

0 0