当心文件 I/O 有错误。

 #include <iostream>
#include <iostream>
#include <numeric>
#include <vector>
#include <list>
#include <set> /* run this program using the console pauser or add your own getch, system("pause") or input loop */ using namespace std; //利用类模板生成类实例
typedef vector < int > IntArray;
typedef list <int> LISTINT;
typedef set<int> SET_INT;
int add(int a, int b) {
return a+b;
}
//在main()函数中测试accumulate算法
int main(int argc, char** argv) {
{
//--------------------------------------------
// accumulate算法对于普通数组的计算
//---------------------------------------------
int x[]={,,,,}; cout<<"x[]:";
for (int i=;i<;i++)
cout<<x[i]<<" ";
cout<<endl;
cout<<"accumulate(x,x+5,0)=";
cout<<accumulate(x,x+,)<<endl;
int val=;
cout<<"val="<<val<<endl;
cout<<"accumulate(x,x+5,val)=";
cout<<accumulate(x,x+,val)<<endl;
//--------------------------------------------
// accumulate算法对于vector容器的计算
//---------------------------------------------
//声明intvector容器和迭代器ii
IntArray intvector;
IntArray::iterator ii; //向intvector容器中插入元素
for (int i=; i<=; i++) {
intvector.push_back(i);
}; //显示intvector容器中的元素值和累加结果
cout << "intvector: "<<endl;
for (ii=intvector.begin();ii !=intvector.end();++ii)
cout<<(*ii)<<" ";
cout<<endl;
cout<<"accumulate(intvector.begin(),intvector.end(),0)=";
cout<<accumulate(intvector.begin(),intvector.end(),)<<endl;
//--------------------------------------------
// accumulate算法对于list容器的计算
//---------------------------------------------
//声明list容器对象和迭代器
LISTINT::iterator iL;
LISTINT list1; //向list1容器对象中插入元素并显示
list1.push_front();
list1.push_front();
list1.push_front();
list1.push_back();
list1.push_back(); //显示list1容器的元素值和累加结果
cout << "list1: "<<endl;
for (iL=list1.begin();iL !=list1.end();++iL)
cout<<(*iL)<<" ";
cout<<endl;
cout<<"accumulate(list1.begin(),list1.end(),0)=";
cout<<accumulate(list1.begin(),list1.end(),)<<endl;
//--------------------------------------------
// accumulate算法对于set容器的计算
//---------------------------------------------
//声明set容器对象和迭代器
SET_INT set1;
SET_INT::iterator si; //向set1容器中插入元素
set1.insert();
set1.insert();
set1.insert();
set1.insert();
set1.insert(); //显示set1容器的元素值和累加结果
cout <<"set1: "<<endl;
for (si=set1.begin();si !=set1.end();++si)
cout<<(*si)<<" ";
cout<<endl;
cout<<"accumulate(set1.begin(),set1.end(),0)=";
cout<<accumulate(set1.begin(),set1.end(),)<<endl;
cout<<"accumulate(set1.begin(),set1.end(),100)=";
cout<<accumulate(set1.begin(),set1.end(),)<<endl;
return ;
}
}

当心文件 I/O 有错误的更多相关文章

  1. 解决vs创建或打开C++浏览数据库文件*.sdf时发生错误的问题

    VS2012,  创建或打开C++浏览数据库文件*.sdf时发生错误. IntelliSense 和浏览信息将不能用于C++项目. 请确保已安装 Microsoft SQL Server Compac ...

  2. Failed: error processing document #281: unexpected EOF,往MongoDB当中插入json文件时出现的错误。

    往MongoDB当中插入json文件时提示的错误(我的操作系统是win10): 当时的执行命令是:mongoimport -d test -c restaurants d://primer-datas ...

  3. php部分---文件上传:错误处理、 客户端和服务器端的限制

    1.客户端页面 <!---客户端的配置 1.表单页面 2.表单发送方式为post 3.表单form中添加enctype="multipart/form-data" ----- ...

  4. 打开FTP服务器上的文件夹时发生错误,请检查是否有权限访问该文件夹

    打开FTP服务器上的文件夹时发生错误,请检查是否有权限访问 在win98,winme,win2000,win2003下都能正常上传文件夹,但在winxp+sp2下同样的文件夹就可能出现问题 1. 打开 ...

  5. uploadify 上传文件出现HTTP 404错误

    今天在使用jquery.uploadify.js上传文件的时候,出现HTTP 404错误,此错误在上传较小文件时不会出现,在上传一个50M左右文件时出现此错误,经过测试和日志查看发现,根本没有进入后台 ...

  6. Lua学习笔记4. coroutine协同程序和文件I/O、错误处理

    Lua学习笔记4. coroutine协同程序和文件I/O.错误处理 coroutine Lua 的协同程序coroutine和线程比较类似,有独立的堆栈.局部变量.独立的指针指令,同时又能共享全局变 ...

  7. 用winscp从本地上传文件到服务器上出现复制文件到远端时错误。

    用winscp从本地上传文件到服务器上出现复制文件到远端时错误. 错误码:4 服务器返回的错误消息:write failed 报错如下图所示: 分析过程: 1.刚开始以为是权限不够,后面上网查了一下是 ...

  8. 用javah 导出类的头文件, 常见的错误及正确的使用方法

    ******************************************************************************** 用javah 导出类的头文件, 常见的 ...

  9. 安装Redis 编译make gcc: error trying to exec 'cc1': execvp: 没有该文件或目录的错误

    Linux(Redhat) make: gcc: error trying to exec 'cc1': execvp: 没有该文件或目录的错误 排查错误: 1.检查gcc.gcc-c++是否安装rp ...

随机推荐

  1. Python continue

    continue继续循环在循环过程中,可以用break退出当前循环,还可以用continue跳过后续循环代码,继续下一次循环.假设我们已经写好了利用for循环计算平均分的代码: L = [75, 98 ...

  2. 阿里云RDS实例内不同数据库之间的数据迁移

    适用场景 本文适用于使用DTS实现相同实例下库名不同的数据库之间的数据迁移.本文以使用DTS将同一RDS实例下的amptest库迁移到jiangliu_amptest库为例来说明如何使用DTS实现相同 ...

  3. Android SDK 快速安装方法

    我们都知道使用Android sdk manager下载安装sdk速度非常慢,一般在10k/s以内,本文章推荐一种能够借助迅雷等下载工具下载sdk的zip包从而快速安装sdk的方法. 1.下载3个xm ...

  4. FFmpeg在Linux下编译使用

    文章转自:http://www.cnblogs.com/CoderTian/p/6655568.html 1.FFmpeg编译 1.1.安装yasm 这里我是直接通过ubuntu包安装的,当然也可以通 ...

  5. RMAN Recovery Catalog

    RMAN用来存放数据库元数据的schema. the catalog includes the following types of metadata:-Data file and archived ...

  6. SQLyog之MySQL客户端的下载、安装和使用(企业版)(破解)

    本博文的主要内容有 .SQLyog的下载 .SQLyog的安装 .SQLyog的使用 1.SQLyog_Enterprise的下载 比如,我这里,是放在D:\SoftWare 继续

  7. 细说websocket - php篇(未完)

    下面我画了一个图演示 client 和 server 之间建立 websocket 连接时握手部分,这个部分在 node 中可以十分轻松的完成,因为 node 提供的 net 模块已经对 socket ...

  8. 字符串函数---itoa()函数具体解释及实现

    itoa()函数 itoa():char *itoa( int value, char *string,int radix); 原型说明: value:欲转换的数据. string:目标字符串的地址. ...

  9. Atitit.故障排除系列---NoClassDefFoundError NoClassDefFoundError

    Atitit.故障排除系列---NoClassDefFoundError  NoClassDefFoundError java.lang.ClassNotFoundException找不到类异常.当应 ...

  10. 用EA生成实体层代码

    在个人版机房重构中.实体层的代码敲得有点儿烦了.不同的实体仅仅是命名不同.代码结构全然一样.遇到反复的事情,就该动动脑.想想办法了. 以下给大家介绍使用EA生成实体层的代码. 首先.建一个类,注意选择 ...