#include <iostream>
#include <time.h>
#include <vector>
using namespace std;
void print_array(int* arr, int n) {
for (size_t i = 0; i < n; i++) {
cout << arr[i] << " ";
}
cout << endl;
int* auto_input_array(int* arr, int n) {
arr[i] = rand() % 160 + 150;
return arr;
void print_vector(vector<int> vec) {
for (int elem : vec) {
cout << elem << " ";
pair<vector<int>, vector<int>> odd_and_even_number_filling_vectors(int* arr, int n) {
vector<int> vec1,vec2;
if (arr[i] % 2 == 1) {
vec1.push_back(arr[i]);
else {
vec2.push_back(arr[i]);
return make_pair(vec1, vec2);
pair<int*, int*> odd_and_even_number_filling_arrays(int* arr, int n) {
int* arr1 = new int[n];
int* arr2 = new int[n];
int count1 = 0;
int count2 = 0;
arr1[count1] = arr[i];
count1++;
arr2[count2] = arr[i];
count2++;
for (size_t i = count1; i < n; i++) {
arr1[i] = 0;
for (size_t i = count2; i < n; i++) {
arr2[i] = 0;
return make_pair(arr1, arr2);
int main() {
srand(time(NULL));
setlocale(LC_ALL, "Russian");
int n;
cout << "Введите количество строк в массиве: ";
cin >> n;
int* array = new int[n];
pair<vector<int>, vector<int>> pair_vecs;
pair<int*, int*> pair_arrs;
array = auto_input_array(array, n);
print_array(array, n);
pair_vecs = odd_and_even_number_filling_vectors(array, n);
pair_arrs = odd_and_even_number_filling_arrays(array, n);
delete[] array;
cout << "Чётных элементов: ";
print_vector(pair_vecs.second);
cout << "Нечётных элементов: ";
print_vector(pair_vecs.first);
cout << "С использованием массивов:" << endl;
print_array(pair_arrs.second, n);
print_array(pair_arrs.first, n);
#include <iostream>
#include <time.h>
#include <vector>
using namespace std;
void print_array(int* arr, int n) {
for (size_t i = 0; i < n; i++) {
cout << arr[i] << " ";
}
cout << endl;
}
int* auto_input_array(int* arr, int n) {
for (size_t i = 0; i < n; i++) {
arr[i] = rand() % 160 + 150;
}
return arr;
}
void print_vector(vector<int> vec) {
for (int elem : vec) {
cout << elem << " ";
}
cout << endl;
}
pair<vector<int>, vector<int>> odd_and_even_number_filling_vectors(int* arr, int n) {
vector<int> vec1,vec2;
for (size_t i = 0; i < n; i++) {
if (arr[i] % 2 == 1) {
vec1.push_back(arr[i]);
}
else {
vec2.push_back(arr[i]);
}
}
return make_pair(vec1, vec2);
}
pair<int*, int*> odd_and_even_number_filling_arrays(int* arr, int n) {
int* arr1 = new int[n];
int* arr2 = new int[n];
int count1 = 0;
int count2 = 0;
for (size_t i = 0; i < n; i++) {
if (arr[i] % 2 == 1) {
arr1[count1] = arr[i];
count1++;
}
else {
arr2[count2] = arr[i];
count2++;
}
}
for (size_t i = count1; i < n; i++) {
arr1[i] = 0;
}
for (size_t i = count2; i < n; i++) {
arr2[i] = 0;
}
return make_pair(arr1, arr2);
}
int main() {
srand(time(NULL));
setlocale(LC_ALL, "Russian");
int n;
cout << "Введите количество строк в массиве: ";
cin >> n;
int* array = new int[n];
pair<vector<int>, vector<int>> pair_vecs;
pair<int*, int*> pair_arrs;
array = auto_input_array(array, n);
print_array(array, n);
pair_vecs = odd_and_even_number_filling_vectors(array, n);
pair_arrs = odd_and_even_number_filling_arrays(array, n);
delete[] array;
cout << "Чётных элементов: ";
print_vector(pair_vecs.second);
cout << "Нечётных элементов: ";
print_vector(pair_vecs.first);
cout << "С использованием массивов:" << endl;
cout << "Чётных элементов: ";
print_array(pair_arrs.second, n);
cout << "Нечётных элементов: ";
print_array(pair_arrs.first, n);
}