Home > Back-end >  C runtime error signal SIGSEGV problems
C runtime error signal SIGSEGV problems

Time:10-03

# include
# include
# include
Int finding (char [], a char [] b)
[100]={0} {char c, d [200000]={0};
Int flag=0;
int k;
for(int i=0; i[I]=c toupper (a [I]);
for(int i=0; i{if (b [I]==' ')
D=b [I] [I];
The else
D=toupper [I] [I] (b); }
If ((strlen (c)==strlen (d)) & amp; & (STRCMP (c, d)==0))
{
printf("1");
return 0;
}
The else {for (int I=0; i{if (STRNCMP (d, c, strlen (c))==0 & amp; & D [strlen (c)]==' ')
{
flag=1;
k=0;
break;
}
The else {the if (I + strlen (c)!=strlen (d))
{if ((STRNCMP (d + I, c, strlen (c))==0) & amp; & [I - 1) (d==") & amp; & D [I + strlen (c)]==' ')
{
flag=1;
K=I;
break;
}}
The else {if ((STRNCMP (d + I, c, strlen (c))==0) & amp; & (d] [I - 1=="))
{
flag=1;
K=I;
break;
}
}}}}
If (flag==0) {printf (" None ");
return 0; }
The else printf (" % d ", k + 1);
return 0;
}
Void main ()
{
Int CNT.
The scanf (" % d ", & amp; CNT);
for(int i=0; i{
Char a [100], [200000] b;
Gets (a);
Gets (b);
Printf (" case # % d: \ n ", I);
Finding (a, b);
printf("\n");
}
}

CodePudding user response:



W has a word, the output it from left to right in the string S position of the first appearance of independence IDX (set S position of the first character in to 1), W only consist of English letters, S except English letters and Chinese characters in any position (including the head and tail) and one or more consecutive Spaces,

Find word, case-insensitive, but requires complete match, namely words W must be with the one in the S independence in the case of a case-insensitive match exactly, W is part of a word in the S alone is not matching,
Input format

Line 1: an integer T (1 T or less 10 or less) as the question number,

The next line of 2 t, 2 lines corresponding to each question, said W and S (1 W or less length of 10 or less; 1 S length or less 1000000 or less),
The output format

Output one line for each problem, the problem of the serial number (0 number, format: case # 0, etc.),

Then the output corresponding to each question on a line independence IDX,
S not find W output None,
The sample
Input

3
IN
Find a word within a string in English and in Chinese.
To
Find a word within a string in English and in Chinese.
In
Find a word within a string in English and in Chinese.

The Output

Case # 0:
29
Case # 1:
None
Case # 2:
33

  • Related