Vector

 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
// Vector.cpp: определяет точку входа для консольного приложения.
//
#include "stdafx.h"
#include <iostream>
#include <conio.h>
#include <vector>
using namespace std;
//void Input(int[][]);
//void Solution(int[][]);
int _tmain(int argc, _TCHAR* argv[])
{
vector <int> one;
int c, tmp;
///
cout << "Enter quentity: ";
cin >> c;
vector <vector <int>> matrix;
cout << "Enter ARRAY: " << endl;
for (int i = 0; i < c; i++)
{
cout << "[" << i + 1 << "]: ";
cin >> tmp;
one.push_back(tmp);
}
///
int k = 0, n = 0;
for (int i = 0; i < c; i++)
{
if (one[i] % 2 == 0)
{
matrix[0][k] = one[i];
k++;
}
else
{
matrix[1][n] = one[i];
n++;
}
}
cout << "Even: ";
for (int i = 0; i < k; i++)
cout << matrix[0][i] << " ";
cout << endl;
cout << "Odd: ";
for (int i = 0; i < n; i++)
cout << matrix[1][i] << " ";
_getch();
return 0;
}