Advertisement
Guest User

Untitled

a guest
Nov 19th, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.82 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include "iostream"
  3. #include "iomanip"
  4. #include "time.h"
  5. #include "algorithm"
  6. #include "stdlib.h"
  7. using namespace std;
  8.  
  9. int main()
  10. {
  11.     int const n = 25, m = 37;
  12.     int i, j, a[n], b[m], c[n+m+1], k = 0;
  13.     srand(time(NULL));
  14.  
  15.  
  16.     a[0] = rand() % 5;
  17.     for (i = 1; i < n; i++)
  18.         a[i] = a[i - 1] + rand() % 5;
  19.     b[0] = rand() % 5;
  20.     for (j = 1; j < m; j++)
  21.         b[j] = b[j - 1] + rand() % 5;
  22.  
  23.  
  24.     for (int i = 0; i < n; i++) {
  25.         bool f = true;
  26.         for (int j = 0; j < m; j++) {
  27.             if (a[i] == b[j]) f = false;
  28.             }
  29.         if (f==true) c[k++] = a[i];
  30.     }
  31.  
  32.     for (int i = 0; i < n; i++) cout << a[i] << " ";
  33.     cout << endl;
  34.     for (int j = 0; j < m; j++) cout << b[j] << " ";
  35.     cout << endl;
  36.     sort(c ,c + k);
  37.     for (int r = 0; r < k; r++) cout << c[r] << " "; cout << endl;
  38.     system("pause");
  39.     return 0;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement