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=-1;
	int x=strlen(a);
	int y=strlen(b);	
	for(int i=0;i<x;i++){
	char c[100000];
		int k=0;
		for(int j=i;j<y+i;j++){
			c[k++]=a[j];
		}
		if(strcmp(c,b)==0){
			flag=i;
			break;
		}
	}
	if(flag==-1){
		cout<<"-1";
	}else{
		cout<<flag+1;
	} 
   return 0;
}

Double click to view unformatted code.


Back to problem 3832