当心文件 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 ...
随机推荐
- 将图片转成base64字符串并在JSP页面显示的Java代码
*本事例主要讲了如下几点: * 1:将图片转换为BASE64加密字符串. * 2:将图片流转换为BASE64加密字符串. * 3:将BASE64加密字符串转换为图片. * 4:在jsp文件中以引 ...
- vue + 百度地图api
主要分解为如下步骤: (1)在html文件中引入百度地图, <script type="text/javascript" src="http://api.map.b ...
- OJ帐号保存
TOJ 614173971 HDU 宇智波佐助 POJ shiai ZOJ henyumen UVa henyumen Light OJ HENYUMEN bzoj henyumen ural 165 ...
- 纯css实现单行”截取“
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- OFBiz:初始RequestHandler
RequestHandler,可以称之为请求处理器,在ControlServlet.init()中初始化: public class ControlServlet extends HttpServle ...
- hdu 4494 Teamwork (可行流的最小流)
去年通话邀请赛的B题,当时居然过的那么少...明明是一道非常裸的可行流最小流麽..仅仅要对每种人分别求一下可行最小流加起来就能够了.建图是对每一个点拆点,容量上下届都设为v[i],然后每一个点间能连边 ...
- 【LeetCode】102. Binary Tree Level Order Traversal (2 solutions)
Binary Tree Level Order Traversal Given a binary tree, return the level order traversal of its nodes ...
- android的NDK和java进行本地socket通信
关于Android应用与Framework的socket通信,相信关心这个问题的朋友们已经看过<android使用socket使底层和framework通信>这篇文章,美中不足的是作者只贴 ...
- Android编程的写法规范
一.获取View对象 1.private EditText m_txtSmsPhone = null;//定义一个EditText控件的调用对象 m_表示为View对象 txt表示文本框 2.在pro ...
- opensips编译安装时可能遇到的问题
错误一: ERROR: could not load the script in /usr/local//lib64/opensips/opensipsctl/opensipsdbctl.pgsql ...