#include<iostream>
#include<cstring>
#include<string>
#include<cstdio>
using namespace std;
int main()
{
string key, word, str;
int first, count = 0, flag = 1, fpos, epos;
getline(cin,key);
getline(cin,str);
str += ' ';
int l1 = key.size();
int l2 = str.size();
for (int i = 0;i < l2;i++)
{
if (str[i] != ' ')
{
flag = 1;
fpos = i;
for (int j = i + 1;j < l2;j++)
{
if (str[j] == ' ')
{
epos = j;
break;
}
}
word = str.substr(fpos, epos - fpos);
if (word.size() == l1)
{
for (int j = 0;j < l1;j++)
{
if (toupper(word[j]) != toupper(key[j]))
{
flag = 0;
break;
}
}
}
else
{
flag = 0;
}
if (flag)
{
count++;
if (count == 1)
{
first = fpos;
}
}
i = epos;
}
}
if (count!=0)
{
cout << count << " " << first << endl;
}
else cout << -1;
return 0;
}
统计单词数NOIP2011普及组第2题
最新推荐文章于 2024-07-23 18:02:17 发布