Home > Back-end >  Output is less a lot of data and how to fix it?
Output is less a lot of data and how to fix it?

Time:09-19

[problem description] input two strings str1 and str2, output str2 in str1 all position, no, no output,
[form] input
[] output form
[the] sample input abcabcabc
Ab
[sample output] 0 3 6
 # include 
# include
Int main () {
Str2 char str1 [80], [80].
Gets (str1);
Gets (str2);
Int len1 len2;
Len1=strlen (str1);
Len2=strlen (str2);
If (len1 & lt; Len2) {
Printf (" no "reason \ n");
}
Int I, j=0, k=0, flag=0;
for(i=0; ifor(; JIf (str1==str2 [j] [I]) {
k++;
}
}
If (k==len2-1) {
Printf (" % d ", I - len2 + 2);
K=0;
flag=1;
}
}
If (flag=0) {
Printf (" \ n ");
}
return 0;
}


Only output a 0

CodePudding user response:

for(; JIf (flag=0)
The two

 # include 
# include
Int main () {
Str2 char str1 [80], [80].
Gets (str1);
Gets (str2);
Int len1 len2;
Len1=strlen (str1);
Len2=strlen (str2);
If (len1 & lt; Len2) {
Printf (" no "reason \ n");
}
Int I, j=0, k=0, flag=0;
for(i=0; ifor(j=0; JIf (str1==str2 [j] [I]) {
k++;
}
}
If (k==len2-1) {
Printf (" % d ", I - len2 + 2);
K=0;
flag=1;
}
}
If (flag==0) {
Printf (" \ n ");
}
return 0;
}


  • Related