include<fstream>
#include<iostream>
#include<string>
#include<cassert>
#include<cfloat>
using namespace std;
int main()
{
cout<<" This program computes the number, maximum,minimum,and\n"
<<"average of an input list of numbers in one file,\n"
<<"and places its results in another file.\n\n";
//--------------------------输入部分----------------------------
cout<<"Entert the name of the input file:";
string inputFileName;
getline(cin,inputFileName);
ifstream inStream;
inStream.open(inputFileName.data());
assert(inStream.is_open());
int count=0;
double reading,
maximum=DBL_MIN,
minimum=DBL_MAX,
sum=0;
for(;;){
inStream>>reading;
if( inStream.eof() )
break;
count++;
sum+=reading;
if (reading<minimum)
minimum=reading;
if(reading>maximum)
maximum=reading;
}
inStream.close();
//-------------------------------------------
cout<<"Enter the name of the output file:";
string outputFileName;
getline(cin,outputFileName);
ofstream outStream;
outStream.open(outputFileName.data());
assert( outStream.is_open() );
outStream<<"\n-->There were"<<count<<"values";
if(count>0)
outStream<<"\n\tranging from"<<minimum
<<" to "<<maximum
<<"\n\tand their average is " <<sum/count
<<endl;
outStream.close();
cout<<"processing complete.\n";
return 0;
}