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. UML解析

    1.1 UML基础知识扫盲 UML这三个字母的全称是Unified Modeling Language,直接翻译就是统一建模语言,简单地说就是一种有特殊用途的语言. 你可能会问:这明明是一种图形,为什 ...

  2. yum 使用笔记

    yum 重新配置了源以后,用 yum clean all 先clean一下,才能用新的.

  3. python startswith与endswith

    如果你要用python匹配字符串的开头或末尾是否包含一个字符串,就可以用startswith,和endswith比如:content = 'ilovepython'如果字符串content以ilove ...

  4. react核心知识点高度总结

    本文系统的将react的语法以最简练的方式列举出来 安装 写在前面 JSX 组件的定义 state 生命周期 方法 条件渲染 列表 表单 组合嵌套 扩展语法 context传递props 错误拦截 r ...

  5. Struts旅程(六)Struts页面转发控制ActionForward和ActionMapping

    转自:https://blog.csdn.net/lovesummerforever/article/details/19125933

  6. NSOperation/NSOperationQueue详细使用介绍

      一.简介 (1)是使用GCD实现的一套Objective-C的API (2)是面向对象的线程技术 (3)提供了一些在GCD中不容易实现的特性,如:限制最大并发数量.操作之间的依赖关系   NSOp ...

  7. GET与POST方法

    HTTP中的GET,POST,PUT,DELETE对应着对这个资源的查,改,增,删4个操作.GET一般用于获取/查询资源信息,而POST一般用于更新资源信息. 1.根据HTTP规范,GET用于信息获取 ...

  8. 第3章 springboot接口返回json 3-2 Jackson的基本演绎法

    @JsonIgnore private String password; @JsonFormat(pattern="yyyy-MM-dd hh:mm:ss a",locale=&q ...

  9. sql编写注意

    DROP TABLE IF EXISTS `imooc_pro`; CREATE TABLE `imooc_pro`( `id` int unsigned auto_increment key, `p ...

  10. Struts2框架01【如果使用struts框架】【利用struts框架写一个 hello world】

    1 什么是Struts2框架 基于MVC设计模式的web应用框架 Struts2框架是一个轻量级的MVC流程框架 轻量级是指程序的代码不是很多,运行时占用的资源不是很多,MVC流程框架就是说它是支持分 ...