We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent f6de997 commit 334fbb5Copy full SHA for 334fbb5
W12/Q5.c
@@ -0,0 +1,33 @@
1
+#include <stdio.h>
2
+#include <stdlib.h>
3
+
4
+int main(void) {
5
+ int i, j, n, m;
6
+ scanf("%i %i ", &n, &m);
7
+ char string1[n + 1], string2[n + 1];
8
+ for (i = 0; i < n; i ++) {
9
+ scanf("%c", &string1[i]);
10
+ }
11
+ string1[n] = '\0';
12
13
+ scanf(" ");
14
15
+ for (i = 0; i < m; i ++) {
16
+ scanf("%c", &string2[i]);
17
18
+ string2[m] = '\0';
19
20
+ int count = 0;
21
+ for (i = 0; i <= n - m; i ++) {
22
+ count = count + 1;
23
+ for (j = 0; j < m; j ++) {
24
+ if (string1[i + j] != string2[j]) {
25
+ count = count - 1;
26
+ break;
27
28
29
30
31
+ printf("%i", count);
32
+ return 0;
33
+}
0 commit comments