码迷,mamicode.com
首页 > 其他好文 > 详细

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

时间:2017-12-05 18:47:23      阅读:180      评论:0      收藏:0      [点我收藏+]

标签:get   turn   统计   str   cstring   noip   ++   std   ace   

 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 }

 

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

标签:get   turn   统计   str   cstring   noip   ++   std   ace   

原文地址:http://www.cnblogs.com/tflsnoi/p/7988589.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!