Home > Back-end >  Judge the child character program
Judge the child character program

Time:09-21

#include
#include
#include
using namespace std;
Int STRSTR (char [] s1 and char [] s2);
Int main ()
{
Char a [10], [10] b;
Int c=0;
Cin. Getline (a, 10);
Cin. Getline (b, 10);
C=STRSTR (a, b);
The switch (c)
{
Case 0:
Cout<& lt;" B is an empty string array cannot compare, "& lt; break;
Case 1:
Cout<& lt;" After comparison of b is not a substring "& lt; break;
Default:
Cout<& lt;" B is a string, "& lt; }
return 0;


}
Int STRSTR (char [] s1 and char [] s1)
{
If (s2 [0]==0)
return 0;
for(int i=0; S1 [I]; I++)
{
Int k=I, j=0;
for(; S2 [j]; + +, k + + j)
{
If (s1 [k]! [j]=s2)
break;
}
If (s2 [j]==0)
return i;
}
return -1;
}
Program compile error:
Line 28 30 D: \ DXJ \ subarray. CPP [Error] redefinition of 'char * s1'
Line 28 20 D: \ DXJ \ subarray. CPP [Error] 'char * s1' previously declared here
30 lines of 5 D: \ DXJ \ subarray. CPP [Error] 's2' was not declared in this scope

CodePudding user response:

I was a stupid newbie, bosses positive guidance, strives for the word

CodePudding user response:

String, it is ok to use pos function directly ~ ~
  • Related