Vector (mine)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
// Vector.cpp: определяет точку входа для консольного приложения.
//
#include "stdafx.h"
#include <iostream>
#include <conio.h>
#include <vector>
using namespace std;
void Input(vector <int> , int);
void Solution(vector <int> &, int);
int _tmain(int argc, _TCHAR* argv[])
{
vector <int> one;
int number;
cout << "Enter the number of elements: ";
cin >> number;
Input(one, number);
Solution(one, number);
_getch();
return 0;
}
void Input(vector <int> one, int number)
{
int tmp;
for (int i = 0; i < number; i++)
{
cout << "[" << i+1 << "]: ";
cin >> tmp;
one.push_back(tmp);
}
}
void Solution(vector <int> & one, int number)
{
vector <int> even;
vector <int> odd;
int k = 0,
m = 0;
for (int i = 0; i < number; i++)
{
if (one[i] % 2 == 0)
{
even.push_back(one[i]);
k++;
}
else
{
odd.push_back(one[i]);
m++;
}
}
cout << "EVEN: ";
for (int i = 0; i < k; i++)
cout << even[i] << " ";
cout << endl;
cout << "ODD: ";
for (int i = 0; i < m; i++)
cout << odd[i] << " ";
}