求助40分后面全RE
查看原帖
求助40分后面全RE
737681
987zz楼主2022/8/31 20:33
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
	int count=0,first;
	string a,b;
	getline(cin,a);
	getline(cin,b);
	for(int i=0;i<b.size();i++)
	{
		if(isupper(b[i])||isupper(a[i]))
		{
			b[i]=tolower(b[i]);
			a[i]=tolower(a[i]);
		}
	} 
	bool flag=true;
	for(int i=0;i<b.size();i++)
	{
		int j=i;
		int k=0;
		while(b[j]!=' '&&j<b.size())
		{
			if(a[k]==b[j])
			{
				k++;
			}
			else
			break;
			if(k==a.size()&&(b[j+1]==' '||j==b.size()-1))
			{
				count++;
			}
			j++;
		}
		i=j;
		if(count==1&&flag)
		{
			first=j-a.size();
			flag=false;
		}
	 } 
	if(count>=1)
	cout<<count<<" "<<first;
	else
	cout<<-1;
	return 0;
}
2022/8/31 20:33
加载中...