include iostream include vector include iterator using namespace std i

 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
#include <iostream>
#include <vector>
#include <iterator>
using namespace std;
int matr[11][2] = {
{1,10},
{2,11},
{3,11},
{4,11},
{5,11},
{6,10},
{7,11},
{8,11},
{9,11},
{10,11},
{11,10}
};
int main(){
vector<int> magic;
vector<int>::iterator iterator;
int n;
cin >> n;
for(int i=0; i<11; i++){
magic.push_back(matr[i][1]);
}
iterator = magic.begin();
while(++iterator != magic.end()){
if(*iterator == *(iterator-1)){
int cur_i_el = 1;
while(*(iterator+1) == *iterator){
if(++cur_i_el != n){
magic.erase(iterator);
}
iterator++;
}
}
}
for(int i=0; i<magic.size(); i++)
cout << magic[i] << endl;
return 0;
}