字符串最大跨距
程序员文章站
2022-03-08 14:03:51
...
#include<bits/stdc++.h>
using namespace std;
int main()
{
string s,s1,s2;
int i=0;
char a;
while(cin>>a)
if(a!=',')
{
if(i==0) s+=a;
else if(i==1) s1+=a;
else s2+=a;
}
else i++;
int t1,t2;
t1=s.find(s1); t2=s.rfind(s2);
if(t1!=-1&&t2!=-1&&(t1+s1.length()-1)<t2)
cout<<t2-t1-s1.length()<<endl;
else cout<<"-1"<<endl;
}
上一篇: 字符串分割
下一篇: win10安装Mysql8.0.19