From f434c2e894dfdcf002c5cf4d6e9b3c59c82ea0e8 Mon Sep 17 00:00:00 2001 From: Misha Date: Tue, 30 Sep 2025 15:18:02 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A3=D0=B4=D0=B0=D0=BB=D0=B8=D1=82=D1=8C=20me?= =?UTF-8?q?rgedarray.cpp?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mergedarray.cpp | 63 ------------------------------------------------- 1 file changed, 63 deletions(-) delete mode 100644 mergedarray.cpp diff --git a/mergedarray.cpp b/mergedarray.cpp deleted file mode 100644 index 36019fc..0000000 --- a/mergedarray.cpp +++ /dev/null @@ -1,63 +0,0 @@ -#include -using namespace std; - -void show(int* a, int n) { - for (int i = 0; i < n; ++i, ++a) { - cout << *a << " "; - } - cout << "\n"; -} - -int main() { - srand(time(0)); - - int M, N; - cout << "Enter the size of array A: "; - if (!(cin >> M) || M <= 0) { - cerr << "Error: size A must be a positive number!\n"; - return 1; - } - - cout << "Enter the size of array B: "; - if (!(cin >> N) || N <= 0) { - cerr << "Error: size B must be a positive number!\n"; - return 1; - } - - int* A = new int[M]; - int* B = new int[N]; - - for (int i = 0; i < M; i++) { - A[i] = rand() % 101 - 50; - } - for (int i = 0; i < N; i++) { - B[i] = rand() % 101 - 50; - } - - int sizeC = M + N; - int* C = new int[sizeC]; - - int* pA = A; - int* pB = B; - int* pC = C; - - for (int i = 0; i < M; i++, ++pA, ++pC) { - *pC = *pA; - } - for (int i = 0; i < N; i++, ++pB, ++pC) { - *pC = *pB; - } - - cout << "Array A: "; - show(A, M); - cout << "Array B: "; - show(B, N); - cout << "C merged array: "; - show(C, sizeC); - - delete[] A; - delete[] B; - delete[] C; - - return 0; -} \ No newline at end of file