Ai
1 Star 0 Fork 0

zdevt/cpptest

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
std_list.cpp 2.45 KB
一键复制 编辑 原始数据 按行查看 历史
zdevt 提交于 2023-08-13 12:48 +08:00 . up
/*
* =====================================================================================
*
* 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;
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/zdevt/cpptest.git
git@gitee.com:zdevt/cpptest.git
zdevt
cpptest
cpptest
master

搜索帮助