sort_unique_copy

///////////////////////////////////////////////////////////
// Copyright (c) 2013, ShangHai Onewave Inc.
//
// FileName: sort_unique_copy.cpp
//
// Description:
//
// Created: Thu Mar 27 09:44:51 2014
// Revision: Revision: 1.0
// Compiler: g++
//
/////////////////////////////////////////////////////////// #include <iostream>
#include <list>
#include <string>
#include <algorithm> using namespace std; int main(void)
{
list<string> m_list;
m_list.push_back("c");
m_list.push_back("cc");
m_list.push_back("b");
m_list.push_back("bb");
m_list.push_back("bb");
m_list.push_back("aa");
m_list.push_back("a"); cout<<"\t--------"<<endl;
for(list<string>::iterator it=m_list.begin(); it!=m_list.end(); it++)
{
cout<<'\t'<<*it<<endl;
} m_list.sort();
cout<<"\t--------"<<endl;
for(list<string>::iterator it=m_list.begin(); it!=m_list.end(); it++)
{
cout<<'\t'<<*it<<endl;
} list<string> m_copyList;
unique_copy(m_list.begin(),m_list.end(),back_inserter(m_copyList));
cout<<"\t--------"<<endl;
for(list<string>::iterator it=m_copyList.begin(); it!=m_copyList.end(); it++)
{
cout<<'\t'<<*it<<endl;
}
return ;
}

g++ -Wall -o sort_unique_copy sort_unique_copy.cpp

./sort_unique_copy

        --------
c
cc
b
bb
bb
aa
a
--------
a
aa
b
bb
bb
c
cc
--------
a
aa
b
bb
c
cc

STL_ALGORITHM_H的更多相关文章

随机推荐

  1. 蓝桥杯 算法训练 ALGO-141 P1102

    算法训练 P1102   时间限制:1.0s   内存限制:256.0MB 定义一个学生结构体类型student,包括4个字段,姓名.性别.年龄和成绩.然后在主函数中定义一个结构体数组(长度不超过10 ...

  2. WCF svcutil工具

    通过SvcUtil.exe生成客户端代码和配置 WCF服务调用通过两种常用的方式:一种是借助代码生成工具SvcUtil.exe或者添加服务引用的方式,一种是通过ChannelFactory直接创建服务 ...

  3. IDEA编译器如何去掉注释中参数错误的提示

    在使用idea的导入别人的项目的时候经常会在方法注释中出现参数错误的提示,这时我们可以参考下面的配置,将方法注释中的参数错误的提示,更新为警告提示~~ 具体使用方法,参考下图~

  4. css3弹性布局语法全解

    本文介绍css3弹性布局的语法 html布局 <div class="box"> <div class="item">1</div ...

  5. 第十章 Executor框架

    在Java中,使用线程来异步执行任务.Java线程的创建与销毁需要一定的开销,如果我们为每一个任务创建一个新线程来执行,这些线程的创建与销毁将消耗大量的计算资源.同时,为每一个任务创建一个新线程来执行 ...

  6. leetcode424

    public class Solution { public int CharacterReplacement(string s, int k) { int len = s.Length; ]; , ...

  7. win 10 提升权限

    问题:每次打开Visual Studio 提示,需要重启以获取管理员权限 解决: 1.Win+R 2.输入:gpedit.msc 3.windows设置->安全设置->本地策略->安 ...

  8. FAILED: Execution Error, return code 2 from org.apache.hadoop

    错误遇到的情形: hive整合hbase,hive的数据表 load,select,insert一切正常 通过hive往hbase关联表插入数据的时候报错,错误内容如下: 2016-04-18 14: ...

  9. 安装Oracle 11.2.0.3 Client Win 32-bit

    第一步:安装Oracle 11.2 32-bit数据库1.双击setup文件,进入安装界面 2.选择跳过升级选项 3.设置oracle安装根目录 4.确认选项,没有问题点击“安装” 第二步:创建数据库

  10. Python 网络爬虫 008 (编程) 通过ID索引号遍历目标网页里链接的所有网页

    通过 ID索引号 遍历目标网页里链接的所有网页 使用的系统:Windows 10 64位 Python 语言版本:Python 2.7.10 V 使用的编程 Python 的集成开发环境:PyChar ...