-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathnum_5.cpp
More file actions
50 lines (46 loc) · 692 Bytes
/
num_5.cpp
File metadata and controls
50 lines (46 loc) · 692 Bytes
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
#include<iostream>
#include<list>
using namespace std;
int main()
{
list<int> A_line;
list<int> B_line;
int number;
int tempt;
cin >> number;
for (int i = 0; i < number; i++)
{
cin >> tempt;
if (tempt % 2)
{
A_line.push_back(tempt);
}
else
{
B_line.push_back(tempt);
}
}
while (A_line.size()>=2 && B_line.size())
{
int A_out;
int B_out;
for (size_t i = 0; i < 2; i++)
{
A_out = A_line.front();
cout << A_out<<" ";
A_line.pop_front();
}
B_out = B_line.front();
cout << B_out<<" ";
B_line.pop_front();
}
for (auto client : A_line)
{
cout << client<<" ";
}
for (auto client : B_line)
{
cout << client<<" ";
}
return 0;
}