#include<iostream>
#include<queue>
#include<string>
using namespace std;
int main()
{
string a, b;
int nb = 0,hh=0;
int rr = 32;
int ans = 0,count =0;
int min[100];
int j = 1;
char c = rr;
getline(cin, a);
getline(cin, b);
for (int i = 0; i < a.size(); i++)
{
a[i] = tolower(a[i]);
}
for (int i = 0; i < b.size(); i++)
{
b[i] = tolower(b[i]);
}
queue<char> n;
queue<char> m;
m.push(c);
for (int i = 0; i < a.size(); i++)
{
n.push(a[i]);
}
for (int i = 0; i < b.size(); i++)
{
m.push(b[i]);
}
//cout << "111"<<m.front() << m.back() << n.front() << n.back() << "111 ";
while (!m.empty())
{
if (m.front() == c)
{
m.pop();
count++;
while (m.front() != c && !(n.empty()))
{
if (m.front() == n.front())
{
m.pop();
count++;
n.pop();
}
else
break;
}
while (!n.empty())
{
n.pop();
}
for (int i = 0; i < a.size(); i++)
{
n.push(a[i]);
}
if (m.front() == c)
{
ans++;
min[j++] = count - 1 - a.size();
nb++;
}
}
if (nb > hh)
{
hh = nb;
continue;
}
m.pop();
count++;
}
if (ans == 0)
cout << -1;
else
cout << ans << " " << min[1];
}
运行没问题。。。
如有帮助,请点击我的回答下方的【采纳该答案】按钮帮忙采纳下,谢谢!