标准模板库

#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<numeric>
#include<list>
using namespace std;

//STL算法 accumulate

//对顺序表元素进行累加求和
 template<class T>

 T sum(T *a, int n)
 {
     //int thesum=0;
     int theProduct = 1;//初始化
     //return accumulate(a, a + n, thesum);//求和
     return accumulate(a, a + n, theProduct, multiplies<T>());//求积
 }

 //copy函数的使用 copy(start,end,to) 
 //template<class T>


void main()
{
    int thesum = 0;
    int a[2] = { 14, 3 };
    cout <<sum<int>(a,2)<< endl;
    list<int> list1;
    list<int> list2;
    list2.push_back(1);
    list2.push_back(2);
    //cout << copy(list2, 2, list1) << endl;

    system("pause");
}
1 STL 简介 ..............................................................................................................................................2 2 顺序性容器...........................................................................................................................................2 2.1 C++ VECTOR(向量容器) ...........................................................................................................2 2.2 C++ LIST(双向链表) .................................................................................................................4 2.3 C++ DEQUE(双向队列) ..................................................................................................................6 2.4 三者比较........................................................................................................................................8 3 关联容器...............................................................................................................................................8 3.1 特点................................................................................................................................................8 3.2 C++ SETS & MULTISETS .................................................................................................................9 3.3 C++ MAPS & MULTIMAPS ............................................................................................................ 11 4 容器适配器.........................................................................................................................................12 4.1 特点..............................................................................................................................................12 4.2 C++ STACKS(堆栈) ..................................................................................................................13 4.3 C++ QUEUES(队列) ......................................................................................................................13 4.4 C++ PRIORITY QUEUES(优先队列)...............................................................................................13 5 迭代器.................................................................................................................................................14 5.1 解释..............................................................................................................................................14 5.2 功能特点......................................................................................................................................14 6 C++标准总结..................................................................................................................................15 6.1 容器..............................................................................................................................................15 6.2 算法..............................................................................................................................................15 6.3 函数对象......................................................................................................................................17 6.4 迭代器..........................................................................................................................................19 6.5 分配器..........................................................................................................................................19 6.6 数值..............................................................................................................................................19
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值