Advertisement
Guest User

Untitled

a guest
Dec 13th, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.54 KB | None | 0 0
  1. #include <stdio.h>
  2. //#include <сonio.h>
  3. #define SIZE_M 10
  4. #define SIZE_N 8
  5. int main()
  6. {
  7.     //int M[SIZE_M] = {1,8,3,-3,21,5,4,523,9,-123};
  8.     //int N[SIZE_N] = {10,8,32,-3,21,4,53,9};
  9.     int MN[SIZE_M+SIZE_N];
  10.  
  11.     int count = 0;
  12.     printf("Введите ваш массив N[8]\n");
  13.     for(int i = 0; i < SIZE_N; i++)
  14.     {
  15.       scanf("%d", &N[i]);
  16.     }
  17.  
  18.     printf("Введите ваш массив M[10]\n");
  19.     for(int i = 0; i < SIZE_M; i++)
  20.     {
  21.       scanf("%d", &M[i]);
  22.     }
  23.  
  24.     printf("Массив M\n");
  25.     for(int i = 0; i < SIZE_M; i++)
  26.     {
  27.         printf("%d ", M[i]);
  28.     }
  29.     printf("\n");
  30.     printf("Массив N\n");
  31.     for(int i = 0; i < SIZE_N; i++)
  32.     {
  33.         printf("%d ", N[i]);
  34.     }
  35.     printf("\n");
  36.  
  37.     int k;
  38.  
  39.     for(int i = 0; i < SIZE_M; i++)
  40.     {
  41.         k = 0;
  42.         for(int j = 0; j < SIZE_N; j++)
  43.         {
  44.             if(M[i] == N[j])
  45.             {
  46.                 k++;
  47.             }
  48.         }
  49.         if(k == 0)
  50.         {
  51.             MN[count++] = M[i];
  52.         }
  53.     }
  54.  
  55.  
  56.  
  57.     int p;
  58.  
  59.     for(int i = 0; i < SIZE_N; i++)
  60.     {
  61.         p = 0;
  62.         for(int j = 0; j < SIZE_M; j++)
  63.         {
  64.             if(N[i] == M[j])
  65.             {
  66.                 p++;
  67.             }
  68.         }
  69.         if(p == 0)
  70.         {
  71.             MN[count++] = N[i];
  72.         }
  73.     }
  74.  
  75.  
  76.  
  77.     printf("Полученный массив MN\n");
  78.     for(int i = 0; i < count; i++)
  79.     {
  80.         printf("%d ", MN[i]);
  81.     }
  82.     printf("\n");
  83.  
  84.     //getch();
  85.  
  86. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement