View Code of Problem 3832

#include<iostream>
#include<string>
using namespace std;
int main()
{
	string a,b;
	while(cin>>a>>b)
	{
		int flag=0;
		for(int i=0;i<a.length();i++)
		{
			string c;
			c=a.substr(i,b.length());
			if(c==b&&flag==0)
			{
				cout<<i+1<<endl;
				flag=1;
			}
		}
		if(flag==0)cout<<-1<<endl;
	}
}

Double click to view unformatted code.


Back to problem 3832