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. 【render】partial及其局部变量

    原文:http://www.cnblogs.com/lwm-1988/archive/2011/09/13/2175041.html 1. partial 1.1 把partial作为view的一部分 ...

  2. VisualGDB系列10:快速调试Linux应用程序

    根据VisualGDB官网(https://visualgdb.com)的帮助文档大致翻译而成.主要是作为个人学习记录.有错误的地方,Robin欢迎大家指正. 本文介绍如何快速调试GCC构建的Linu ...

  3. apache server和tomcat集群配置二:垂直负载

    垂直负载就是同一个机器中的不同服务器之间的负载.跟水平负载(ip不一样的服务器之间的负载)的最大区别就是要修改tomcat的端口号,避免引起冲突. 还要注意apache中workers.propert ...

  4. js 控制标记样式

    做一个变色的标签 鼠标移入变为灰色,移除变回原来的颜色,点击变成黑色,再点击变回,如果变成黑色不受移入移除影响. <body> <div class="bt1" ...

  5. java网络编程安全问题

    客户端与服务器互相传输时传输的数据的原内容会不会被人获取到? 在客户端与服务器之间有很多通信节点,数据在这些节点上传输前,可以先获取他们的安全证书,至于当心怕被修改可以用SSL加密(个人见解,这方面懂 ...

  6. vray学习笔记(3)-多维子材质是个什么东西

    多维子材质是个什么东西?为什么出现这个概念? 在3dsmax官方网站,我们可以看到它的定义: The Multi/Sub-Object material lets you assign differe ...

  7. Django框架 之 URLconf

    Django框架 之 URLconf 浏览目录 URL 摘要 Django如何处理一个请求 反向解析URL name模式 namespace模式 一.URL 1.摘要 我们要在Django项目中为应用 ...

  8. SSH2+proxool 出现No suitable driver found for proxool.mysqlProxool

    SSH2+proxool 出现No suitable driver found for proxool.mysqlProxool 首先我们要明确使用的是SSH2框架,然而Struts2是基于filte ...

  9. MySQL数据导入导出方法与工具mysqlimport

    MySQL数据导入导出方法与工具mysqlimport<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office ...

  10. TCP/IP与套接字

    以前我们讲过进程间通信,通过进程间通信可以实现同一台计算机上不同的进程之间通信. 通过网络编程可以实现在网络中的各个计算机之间的通信. 进程能够使用套接字实现和其他进程或者其他计算机通信. 同样的套接 ...