1. 程式人生 > >1400統計單詞數 (noip2011普及組第2題)

1400統計單詞數 (noip2011普及組第2題)

統計單詞 etl space name main turn cin iostream pre

 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題)