BJFUOJ:查找子串第一次出现的位置
strle() 返回数组的长度,X.length() X需要为字符串
cin输入的字符串不能包含空格,gets可以包含空格
#include<bits/stdc++.h>
using namespace std;
int Find (char s1[],char s2[]){
int len1 = strlen(s1);
int len2 = strlen(s2);
for(int i=0;i<len1;i++){
int j1 = i;
int j2 = 0;
while(s1[j1] == s2[j2]){
if(j2 == len2) return i;
j1++;
j2++;
}
if(j2 == len2) return i;
}
return -1;
}
int main(){
while(1){
char s1[100],s2[100];
cin>>s1;
cin>>s2;
if(s1[0] == '0' && s2[0] == '0') break;
int n = Find(s1,s2);
cout<<n<<endl;
}
}