There is a task1()
function that returns an array, and passes it to the button, which in turn passes it to the textBox
.
#pragma once #include <ctime> #include <iomanip> namespace Lab { using namespace std; void initArr(int* arrPtr, const int size) { for (int* arrPtrCpy = arrPtr; arrPtrCpy < arrPtr + size; ++arrPtrCpy) { *arrPtrCpy = rand() % 51 - 25; } } /*int printArr(int* arrPtr, const int size) { for (int* arrPtrCpy = arrPtr; arrPtrCpy < arrPtr + size; ++arrPtrCpy) { if (arrPtr + size == arrPtrCpy) { return *arrPtrCpy; } else { printArr(arrPtr, size); } } }*/ bool isElementExists(const int* arrPtr, const int size, const int item) { bool isExists = false; for (const int* arrPtrCpy = arrPtr; arrPtrCpy < arrPtr + size; ++arrPtrCpy) { if (*arrPtrCpy == item) { isExists = true; break; } } return isExists; } bool isElementExists(const int* arrPtr, const int* endArrPtr, const int item) { bool isExists = false; for (const int* arrPtrCpy = arrPtr; arrPtrCpy < endArrPtr; ++arrPtrCpy) { if (*arrPtrCpy == item) { isExists = true; break; } } return isExists; } int conver(int arrPtr, const int size, int &mass) { for (int i=0;i<size;i++) { *mass[i] = *arrPtr[i]-48; } } int task1() { int sizeA = 5; int sizeB = 5; int* arrAPtr = new int[sizeA]; initArr(arrAPtr, sizeA); int* arrBPtr = new int[sizeB]; initArr(arrBPtr, sizeB); //printArr(arrAPtr, sizeA); //printArr(arrBPtr, sizeB); int sizeC = 0; for (int* arrAPtrCpy = arrAPtr; arrAPtrCpy < arrAPtr + sizeA; ++arrAPtrCpy) { if (!isElementExists(arrAPtr, arrAPtrCpy, *arrAPtrCpy) && !isElementExists(arrBPtr, sizeB, *arrAPtrCpy)) { ++sizeC; } } int* arrCPtr = new int[sizeC]; for (int* arrAPtrCpy = arrAPtr, *arrCPtrCpy = arrCPtr; arrAPtrCpy < arrAPtr + sizeA; ++arrAPtrCpy) { if (!isElementExists(arrAPtr, arrAPtrCpy, *arrAPtrCpy) && !isElementExists(arrBPtr, sizeB, *arrAPtrCpy)) { *arrCPtrCpy = *arrAPtrCpy; ++arrCPtrCpy; } } char *mass= new char [sizeC]; delete[] arrAPtr; delete[] arrBPtr; return arrCPtr; delete[] arrCPtr; } }
At the moment my first array element is displayed.
Question: How can I output the entire array?
Since the courses we have not yet been told what OOP and classes are. I just need a template.
I want the teacher to send homework in a normal form, and not 10 different sourse files.