View Code of Problem 3832

#include<cstdio>
#include<cstring>
#include<cmath>
#include<iostream>
#include<algorithm>
#define N 100
using namespace std;
int ismatch(char a,char b){
	if(a=='('&&b==')'){
		return 1;
	}else if(a=='['&&b==']'){
		return 1;
	}else if(a=='{'&&b=='}'){
		return 1;
	}else{
		return 0;
	}
}
int main()
{
	 char a[100000];
	 char b[100000];
	cin>>a;
	cin>>b;
	int flag=0;
	int x=strlen(a);
	int y=strlen(b);	
	for(int i=0;i<x;i++){
	if(a[i]==b[0]){
		int flag1=0;
		for(int j=0;j<y;j++){
			if(a[i+j]!=b[j]){
				flag1=1;
				break;
			} 
		}if(flag1==0){
			 	cout<<i+1<<endl;
			 	flag=1;
			 	break;
		}
		}
		
	} 
	if(flag==0)
	cout<<"-1"<<endl;
   return 0;
}

Double click to view unformatted code.


Back to problem 3832