SHARE
TWEET

Podniz

a guest Apr 21st, 2019 62 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <stdbool.h>
  4.  
  5. int main() {
  6.     int i, j;
  7.     int n, m;
  8.     int A[100], B[100];
  9.     int index = 0;
  10.     bool flag = false;
  11.  
  12.     // Input
  13.     printf("Unisite velicine nizova A i B: ");
  14.     scanf("%d%d", &n, &m);
  15.  
  16.     for (i = 0; i < n; i++) {
  17.         printf("Niz A, Element %d: ", i);
  18.         scanf("%d", &A[i]);
  19.     }
  20.  
  21.     for (j = 0; j < m; j++) {
  22.         printf("Niz B, Element %d: ", j);
  23.         scanf("%d", &B[j]);
  24.     }
  25.  
  26.     // Calc
  27.     j = 0;
  28.     for (i = 0; i < n; i++) {
  29.         if (B[j++] == A[i]) {
  30.             flag = true;
  31.             if (j >= m) break;
  32.         }
  33.         else {
  34.             flag = false;
  35.             j = 0;
  36.         }
  37.     }
  38.  
  39.     if (flag) {
  40.         printf("Jeste podniz\n");
  41.     }
  42.     else {
  43.         printf("Nije podniz\n");
  44.     }
  45.  
  46.     return 0;
  47. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top