Advertisement
Guest User

1

a guest
Oct 19th, 2017
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.48 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <conio.h>
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.     int n;
  9.     cin >> n;
  10.     int *b = new int[n];
  11.     int *a = new int[n];
  12.     int cnt = 0;
  13.     for (int i = 0; i != n; ++i)
  14.     {
  15.         a[i] = rand() % 20 * pow(-1, rand() % 12);
  16.         cout << a[i] << '\t';
  17.         if (a[i] % 2 == 0)
  18.         {
  19.             b[cnt++] = a[i];
  20.         }
  21.     }
  22.     cout << endl;
  23.     for (int i = 0; i != cnt; ++i)
  24.     {
  25.         cout << b[i] << '\t';
  26.     }
  27.     delete[] a;
  28.     delete[] b;
  29.  
  30.     _getch();
  31.     return EXIT_SUCCESS;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement