当心文件 I/O 有错误
当心文件 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 有错误的更多相关文章
- 解决vs创建或打开C++浏览数据库文件*.sdf时发生错误的问题
VS2012, 创建或打开C++浏览数据库文件*.sdf时发生错误. IntelliSense 和浏览信息将不能用于C++项目. 请确保已安装 Microsoft SQL Server Compac ...
- Failed: error processing document #281: unexpected EOF,往MongoDB当中插入json文件时出现的错误。
往MongoDB当中插入json文件时提示的错误(我的操作系统是win10): 当时的执行命令是:mongoimport -d test -c restaurants d://primer-datas ...
- php部分---文件上传:错误处理、 客户端和服务器端的限制
1.客户端页面 <!---客户端的配置 1.表单页面 2.表单发送方式为post 3.表单form中添加enctype="multipart/form-data" ----- ...
- 打开FTP服务器上的文件夹时发生错误,请检查是否有权限访问该文件夹
打开FTP服务器上的文件夹时发生错误,请检查是否有权限访问 在win98,winme,win2000,win2003下都能正常上传文件夹,但在winxp+sp2下同样的文件夹就可能出现问题 1. 打开 ...
- uploadify 上传文件出现HTTP 404错误
今天在使用jquery.uploadify.js上传文件的时候,出现HTTP 404错误,此错误在上传较小文件时不会出现,在上传一个50M左右文件时出现此错误,经过测试和日志查看发现,根本没有进入后台 ...
- Lua学习笔记4. coroutine协同程序和文件I/O、错误处理
Lua学习笔记4. coroutine协同程序和文件I/O.错误处理 coroutine Lua 的协同程序coroutine和线程比较类似,有独立的堆栈.局部变量.独立的指针指令,同时又能共享全局变 ...
- 用winscp从本地上传文件到服务器上出现复制文件到远端时错误。
用winscp从本地上传文件到服务器上出现复制文件到远端时错误. 错误码:4 服务器返回的错误消息:write failed 报错如下图所示: 分析过程: 1.刚开始以为是权限不够,后面上网查了一下是 ...
- 用javah 导出类的头文件, 常见的错误及正确的使用方法
******************************************************************************** 用javah 导出类的头文件, 常见的 ...
- 安装Redis 编译make gcc: error trying to exec 'cc1': execvp: 没有该文件或目录的错误
Linux(Redhat) make: gcc: error trying to exec 'cc1': execvp: 没有该文件或目录的错误 排查错误: 1.检查gcc.gcc-c++是否安装rp ...
随机推荐
- bash中的命令基本操作
1.命令行编辑功能 命令行编辑功能是指用户可以使用方向键前后移动光标,并编辑已经输入的命令,这个命令非常实用.方便. 提示:可能大多数读者都没有使用过不带命令行编辑功能的shell,有兴趣的读者可以使 ...
- QtGui.QFileDialog
The QtGui.QFileDialog is a dialog that allows users to select files or directories. The files can be ...
- vagrant box各种命令汇总
最近在研究laravel,中间用到了vagrant 虚拟机管理工具,学习一下他的命令 vagrant box命令 用于管理boxes的命令,比如添加.删除等等. 此命令的功能主要通过以下子命令完成: ...
- TP框架M方法 create方法丢失字段问题
TP框架M方法 create方法丢失字段问题! thinkphp框架M方法 create方法丢失字段问题! thinkphp框架M方法 add方法字段丢失问题! 数据库 表新增了字段,用create方 ...
- 跟踪数据库中执行时间超过1.5秒的语句及SP,导入数据库
跟踪 --============================================================================ --新建两个目录 D:\InOut\ ...
- sql通过某个字段名找到数据库中对应的表
sql通过某个字段名找到数据库中对应的表 SELECT sb.name FROM syscolumns s JOIN sysobjects sb ON s.id=sb.id WHERE s.name= ...
- bzoj-1492 货币兑换Cash (2)——CDQ分治
题意: 略 见上一篇 题解: 方程还是那个方程f[i]=A[i] * X[j] + B[i] * Y[j]. 化简为Y[i]=(-A[i]/B[i]) * X[i] + f[i]/B[i]这一坨: 既 ...
- CentOS 6上的redis搭建实战记录(转)
redis 是一个基于内存的高性能key-value数据库,数据都保存在内存中定期刷新到磁盘,以极高的读写效率而备受关注.他的特点是支持各种数据结构,stirng,hashes, list,set,和 ...
- 转:sock_ev——linux平台socket事件框架(基于数据报的测试程序) .
上一篇已经做过注释,这一篇直接上代码 /******************************************************************************** ...
- java web 解决Form表单乱码问题
JSP和Servlet的六种中文乱码处理方法 一.表单提交时出现乱码: 在进行表单提交的时候,经常提交一些中文,自然就避免不了出现中文乱码的情况,对于表单来说有两种提交方式:get和post提交方式. ...