演示文件IO的例子
来源:互联网 发布:淘宝外贸原单死人衣服 编辑:程序博客网 时间:2024/05/21 10:56
#include<iostream>#include<fstream>#include<string>#include<cassert>#include<cfloat>using namespace std;int main(){//-------------输入部分------------------cout<<"Enter the name of the input file:";string inputFileName;getline(cin,inputFileName);ifstream fin;fin.open(inputFileName.data());assert(fin.is_open());int count=0;double reading, max=DBL_MIN, min=DBL_MAX, sum=0.0;for(;;){fin>>reading;if(fin.eof()) break;count++;sum+=reading;if(reading<min)min=reading;if(reading>max)max=reading;}fin.close();//--------------输出部分-------------------cout<<"Enter the name of the output file:";string outputFileName;getline(cin,outputFileName);ofstream fout(outputFileName.data());assert(fout.is_open());fout<<"There were "<<count<<"values";if(count>0)fout<<"\n range from "<<min <<" to "<<max<<"\n and their average is "<<sum/count<<endl;fout.close();cout<<"Processing complete.\n";}
阅读全文
0 0
- 演示文件IO的例子
- IO读写文件/目录 的简单例子
- Lua io的简单演示
- CListCtrl 使用演示的例子
- CListCtrl 使用演示的例子
- 轨迹动画演示的例子
- 简易记事本(演示java文件io)
- IO操作的一个例子(copy文件的命令)
- java关于(io&nio) 的 文件copy例子
- IO的例子
- java基础-用IO演示文件的复制过程(学习笔记)
- 一个简单的例子来演示将stderr 同时 tee 到文件上
- 对java IO BufferedWriter 使用的演示
- 【IO】中InputStream及其方法的演示
- .Net FrameWork SDK文档的例子演示
- DemoShield制作演示盘的例子
- WF综合技术演示的例子
- ExtJS 4 数据包的演示例子
- zookeeper学习记录-06 Zookeeper JavaAPI操作
- Deep Learning:深度前馈神经网络(五)
- 一周五次课(10月20日)
- tornado学习之路
- 自定义View笔记(三) --- ViewDragHelper
- 演示文件IO的例子
- Linux终端部分快捷方式
- C++ 遗传学SFLA混合蛙跳算法
- PopupWindow在7.0上显示的坑
- linux 下 启动mysql服务出错!Starting MySQL.The server quit without updating PID file (XXX.pid)
- Java基础之JMX
- BZOJ 1009: [HNOI2008]GT考试(DP+KMP失配+矩阵快速幂)
- Android 能让你少走弯路的干货整理
- 转发和重定向的对比