当心文件 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. Androidclient性能參数监控

    背景: 在做androidclient測试的时候.有时候须要监控cpu/mem/电量消耗/界面载入时间/流量等等指标. 于是俺们就上下求索,网友告诉我两个方案:AnotherMonitor和Emmag ...

  2. model中设置默认值时 ,使用 lambda 与否的差别以及datetime的默认值方法

    'date': '2013-01-01'  #固定值 'date': time.strftime('%Y-%m-%d')  #启动时候的值 'date': lambda *a: time.strfti ...

  3. 【转】MVC4验证用户登录特性实现方法

    在开发过程中,需要用户登陆才能访问指定的页面这种功能,微软已经提供了这个特性. // 摘要: // 表示一个特性,该特性用于限制调用方对操作方法的访问. [AttributeUsage(Attribu ...

  4. HMM隐Markov模型的原理及应用建模

    这里不讲定量的公式.(由于我也没全然弄明确.不想误人子弟)仅仅谈高速定性理解. 隐Markov模型原理 隐Markov模型(Hidden Markov Model.HMM)的实质就是:已知几种原始分类 ...

  5. js 向上取整、向下取整、四舍五入

      js 向上取整.向下取整.四舍五入 CreateTime--2018年4月14日11:31:21 Author:Marydon // 1.只保留整数部分(丢弃小数部分) parseInt(5.12 ...

  6. 【剑指offer】面试题30:最小的K个数

    import random def partition(data, start, end): if end <= start: return start index = random.randi ...

  7. LaTeX 中文段首空格问题

    一般用 “\\”或者回车可以使得下一段段首空两格,但是对于第一段就不行了. 解决办法:  加一个\usepackage{indentfirst}就可以

  8. HTTP 错误状态码讯息

    HTTP 错误讯息解读   4xx: Client Error 使用者端(浏览器)错误讯息 错误码   错误讯息说明 400 Bad Request    错误的要求 401 Unauthorized ...

  9. window.onunload | window.onbeforeunload

    先引述一段jQuery 官方对于onunload的评述: The unload event is sent to the window element when the user navigates ...

  10. django 常用命令 详解

    check     compilemessages     createcachetable     dbshell     diffsettings     dumpdata     flush   ...