SHARE
TWEET

3 массива

a guest Sep 12th, 2019 78 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include "pch.h"
  2. #include <iostream>
  3.  
  4. using namespace std;
  5.  
  6. int N; //Размерность массивов
  7.  
  8. void fillX(int * x, int * z, int i)
  9. {
  10.     for (int j = N - 1; j >= 0; j--)
  11.     {
  12.         *(z + (2*N - 2) - (2*i)) = *(x + j); i++;
  13.     }
  14. }
  15.  
  16. void fillY(int * y, int * z, int i)
  17. {
  18.     for (int j = 0; j < N; j++)
  19.     {
  20.         *(z + 2*i + 1) = *(y + j); i++;
  21.     }
  22. }
  23.  
  24. int main()
  25. {
  26.    
  27.     cin >> N;
  28.     int * x = new int[N];
  29.     int * y = new int[N];
  30.  
  31.     for (int i = 0; i < N; i++)
  32.     {
  33.         *(x + i) = rand() % 10;
  34.         *(y + i) = rand() % 10;
  35.     }
  36.  
  37.     cout << "First massive: ";
  38.     for (int i = 0; i < N; i++)
  39.         cout << *(x + i) << " ";
  40.     cout << endl;
  41.  
  42.     cout << "Second: ";
  43.     for (int i = 0; i < N; i++)
  44.         cout << *(y + i) << " ";
  45.     cout << endl;
  46.  
  47.     int * z = new int[2 * N];
  48.     int i = 0;
  49.     fillX(x, z, i); fillY(y, z, i);
  50.  
  51.     cout << "massive Z: ";
  52.     for (int i = 0; i < 2*N; i++)
  53.         cout << *(z + i) << " ";
  54.     cout << endl;
  55.  
  56. }
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
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top