Home > Back-end >  Los statistical word string number operation only output 1 o god forever
Los statistical word string number operation only output 1 o god forever

Time:01-21

Idea is the first to seek and find the string is read in, and then use two for loop to a one character at a time, a for used to move the first than characters, a for used to compare whether from the first compare the characters of the back of the same, then the output after judgment, now the question is how it is only the output 1, hope the great god directions, in the HTML code is as follows:
# include
# include
Int main () {
Int q=0, I, j, k, l, first;
Char a [1000000], [11] b;
The scanf (" % s ", b);
getchar();
Gets (a);
K=strlen (a);
L=strlen (b);
for(i=0; ifor(j=0; JIf ((a [I + j]! [j])=b & amp; & (a/I + j!=b [j] + 32 | | a [I + j]!=[j] - 32 b)) {//case regardless of
j--;//here to rule out a situation: the last character range equal end cycle or break out of the value of j, added a j - so, anyway j behind nor
break;
}
}
If (j==l - 1) {
If (q==0)//record for the first time the location of the
The first=I;
Q++;
}
}
If (q==0)
Printf (" 1 ");
The else {
Printf (" % d % d ", q, first);
}
return 0;
}

CodePudding user response:

 # include 
# include
#include

Void str_to_lower (char * STR)
{
int i=0;

While (STR) [I] {
If (isupper (STR [I]))
STR=STR [I] [I] + 32;
i++;
}
}
Int main ()
{

The static char STR [100000].
Char substr [16].
Int I, j, k;
Int first=1, CNT=0;

The fgets (STR, sizeof (STR), stdin);
The scanf (" % s ", substr);


Str_to_lower (STR);
Str_to_lower substr ();

i=0;
While (STR) [I] {
For (j=0; Substr [j] & amp; & STR (I + j), J++) {
If (substr [j].=STR [I + j])
break;
}
Printf (" I=% d \ n ", I);
If (substr [j]=='\ 0') {
If (first==1)
The first=I;
cnt++;
}
If (j!=0)
I +=j;
The else
i++;

}

If (first==1)
Printf (" 1 ");
The else
Printf (" % d % d ", CNT, first);


/*
Int q=0, I, j, k, l, first;
Char a [1000000], [11] b;

The scanf (" % s ", b);
getchar();
Gets (a);
K=strlen (a);
L=strlen (b);
for(i=0; ifor(j=0; JIf ((a [I + j]! [j])=b & amp; & (a/I + j!=b [j] + 32 | | a [I + j]!=[j] - 32 b)) {//case regardless of
j--;//here to rule out a situation: the last character range equal end cycle or break out of the value of j, added a j - so, anyway j behind nor
break;
}
}
If (j==l - 1) {
If (q==0)//record for the first time the location of the
The first=I;
Q++;
}
}
If (q==0)
Printf (" 1 ");
The else {
Printf (" % d % d ", q, first);
}
*/
return 0;
}

For your reference ~
  • Related