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 }

 

转载于:https://www.cnblogs.com/tflsnoi/p/7988589.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值