[Plain] Description
Enter a string 'str' and a substring 's' to count the number of substring 'S.
Input
There are two rows of input data. The first row is str, and the second row is s. the string length cannot exceed 128.
Output
Number of output substrings
Sample Input
Sdf $
Sdf
Sample Output
2
Description
Enter a string 'str' and a substring 's' to count the number of substring 'S.
Input
There are two rows of input data. The first row is str, and the second row is s. the string length cannot exceed 128.
Output
Number of output substrings
Sample Input
Sdf $
Sdf
Sample Output
2
[Plain] # include <stdio. h>
# Include <string. h>
Int main ()
{
Int I;
Int j;
Int l;
Int n;
Int m;
Int count;
Int flag;
Char a [129];
Char B [129];
Gets ();
Gets (B );
N = strlen ();
M = strlen (B );
Count = 0;
For (I = 0; I <n; I ++)
{
Flag = 1;
J = 0;
If (a [I] = B [j])
{
L = I;
For (j = 1; j <m; j ++)
{
If (B [j]! = A [++ l])
{
Flag = 0;
Break;
}
}
If (flag)
{
Count ++;
}
}
}
Printf ("% d", count );
Return 0;
}
# Include <stdio. h>
# Include <string. h>
Int main ()
{
Int I;
Int j;
Int l;
Int n;
Int m;
Int count;
Int flag;
Char a [129];
Char B [129];
Gets ();
Gets (B );
N = strlen ();
M = strlen (B );
Count = 0;
For (I = 0; I <n; I ++)
{
Flag = 1;
J = 0;
If (a [I] = B [j])
{
L = I;
For (j = 1; j <m; j ++)
{
If (B [j]! = A [++ l])
{
Flag = 0;
Break;
}
}
If (flag)
{
Count ++;
}
}
}
Printf ("% d", count );
Return 0;
}