Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "pch.h"
- #include <iostream>
- using namespace std;
- int N; //Размерность массивов
- void fillX(int * x, int * z, int i)
- {
- for (int j = N - 1; j >= 0; j--)
- {
- *(z + (2*N - 2) - (2*i)) = *(x + j); i++;
- }
- }
- void fillY(int * y, int * z, int i)
- {
- for (int j = 0; j < N; j++)
- {
- *(z + 2*i + 1) = *(y + j); i++;
- }
- }
- int main()
- {
- cin >> N;
- int * x = new int[N];
- int * y = new int[N];
- for (int i = 0; i < N; i++)
- {
- *(x + i) = rand() % 10;
- *(y + i) = rand() % 10;
- }
- cout << "First massive: ";
- for (int i = 0; i < N; i++)
- cout << *(x + i) << " ";
- cout << endl;
- cout << "Second: ";
- for (int i = 0; i < N; i++)
- cout << *(y + i) << " ";
- cout << endl;
- int * z = new int[2 * N];
- int i = 0;
- fillX(x, z, i); fillY(y, z, i);
- cout << "massive Z: ";
- for (int i = 0; i < 2*N; i++)
- cout << *(z + i) << " ";
- cout << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement