-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstd_list.cpp
123 lines (96 loc) · 2.12 KB
/
std_list.cpp
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
/*
* =====================================================================================
*
* Filename: Queue.cpp
*
* Description:
*
* Version: 1.0
* Created: 2017年02月23日 16时44分49秒
* Last Modified: 2020-03-07 14:41:13
* Revision: none
* Compiler: gcc
*
* Author: zt (),
* Organization:
*
* =====================================================================================
*/
#include <iostream>
#include <queue>
#include <vector>
#include <list>
#include <string>
/* *************list*********** */
/* back -------------front */
int main ( int argc, char* argv[] )
{
( void ) argc;
( void ) argv;
const int n = 128;
bool Temp[n];
for ( int i = 0; i < n; ++i )
Temp[i] = true;
Temp[0] = false;
Temp[1] = false;
for ( int i = 2; i < n; ++i )
{
for ( int j = i * i; j < n; j = j + i )
{
if ( Temp[j] )
{
if ( j % i == 0 )
Temp[j] = false;
}
}
}
for ( int i = 0; i < n; ++i )
{
if ( Temp[i] )
printf ( "%d ", i );
}
printf ( "\n" );
#if 0
std::list<int> temp;
temp.push_back ( 2 );
//for ( int i = 0; ( 2 * i + 1 ) < 499979; ++i )
for ( int i = 1; ( 2 * i + 1 ) < 109; ++i )
temp.push_back ( 2 * i + 1 );
for ( auto& e : temp )
printf ( "%d ", e );
printf ( "\n" );
for ( auto iter = temp.begin(); iter != temp.end(); ++iter )
{
auto i = iter;
++i;
for ( ; i != temp.end(); )
{
if ( *i % *iter == 0 )
i = temp.erase ( i );
else
++i;
}
}
for ( auto& e : temp )
printf ( "%d ", e );
printf ( "\n" );
#endif
#if 0
std::list< std::vector<char> > container;
std::vector<char> a ( 5, 'a' );
std::vector<char> b ( 6, 'b' );
std::vector<char> c ( 7, 'c' );
container.push_back ( a );
container.push_back ( b );
container.push_back ( c );
a.resize ( 10, 'A' );
container.pop_front();
container.push_front ( a );
while ( !container.empty() )
{
std::cout << "size = " << container.front().size() << std::endl;
container.pop_front();
}
#endif
return 0;
}