STL_ALGORITHM_H
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的更多相关文章
随机推荐
- delphi 在线程中运行控制台命令(console)
在编程开发的时候,我们时常会调用windows本身的功能,如:检测网络通断,连接无线wifi等. 虽然,用 windows api 操作可以完美地完成这些操作,但是,函数参数太难了.令人望而生畏,不是 ...
- 问题:只能在执行 Render() 的过程中调用 RegisterForEventValidation;结果:只能在执行 Render() 的过程中调用 RegisterForEventValidation
只能在执行 Render() 的过程中调用 RegisterForEventValidation 当在导出Execl或Word的时候,会发生只能在执行 Render() 的过程中调用 Register ...
- elasticsearch(3) curl命令
curl 操作http的get/post/put/delete CURL 命令参数-a/--append 上传文件时,附加到目标文件-A/--user-agent <string> 设置用 ...
- CALayer的基本使用
CALayer需要导入这个框架:#import <QuartzCore/QuartzCore.h> 一.CALayer常用属性 属性 说明 是否支持隐式动画 anchorPoint 和中心 ...
- 从文件中读取yuv和h264数据
1.从文件中读取h264数据 参考ffmpeg avc.c写的从文件中一帧帧读取h.264数据的demo #include <stdio.h> #include <stdlib.h& ...
- JAVA基础知识总结5(面向对象特征之一:继承)
继 承: 1:提高了代码的复用性. 2:让类与类之间产生了关系,提供了另一个特征多态的前提. 父类的由来:其实是由多个类不断向上抽取共性内容而来的. JAVA只支持单继承.java虽然不直接支持多继承 ...
- java多线程环境单例模式实现详解
Abstract 在开发中,如果某个实例的创建需要消耗很多系统资源,那么我们通常会使用惰性加载机制,也就是说只有当使用到这个实例的时候才会创建这个实例,这个好处在单例模式中得到了广泛应用.这个机制在s ...
- cd命令无效
原因是没有切换盘符步骤一:C:\Documents and Settings\Administrator>d:步骤二:cd D:\Program Files\Python35-32\Script ...
- var_dump — 打印变量的相关信息
<?php $a = array( 1 , 2 , array( "a" , "b" , "c" )); var_dump ( $a ...
- 【转】pecl,pear的不同
PEAR是PHP扩展与应用库(the PHP Extension and Application Repository)的缩写.它是一个PHP扩展及应用的一个代码仓库,基于php代码的,安装目录在/u ...