1400统计单词数 (noip2011普及组第2题)


 1 #include<cstdio>
 2 #include<cstring>
 3 #include<iostream>
 4 #include<string>
 5 using namespace std;
 6 int main()
 7 {
 8     int t=0,t1=0,l,l2;
 9     string s,ss;
10     getline(cin,ss);
11     getline(cin,s);
12     l2=ss.size();    
13     l=s.size();
14     for(int i=0;i<=l-l2;i++)
15     {
16         for(int j=0;j<l2;j++)
17         {
18             if(toupper(s[i+j])!=toupper(ss[j]))break;
19             if(i>0&&s[i-1]!=' ')break;
20             if(j==l2-1&&(s[i+j+1]==' '||j+i==l))
21             {
22                 ++t;
23                 if(t==1)t1=i;
24             }
25         }
26     }
27     if(t==0)cout<<"-1";
28     else cout<<t<<" "<<t1;
29     return 0;
30 }

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM