/*
*Copyright (c) 2016,烟台大学计算机学院
*All rights reserved.
*文件名称:test.cpp
*作 者:刘亚
*完成日期:2016年 5月 17日
*版 本 号:1.0
*
*问题描述:文件的应用
*输入描述:
*程序输出: MAX
*/
#include <iostream>
#include<fstream>
#include<cstdlib>
using namespace std;
*Copyright (c) 2016,烟台大学计算机学院
*All rights reserved.
*文件名称:test.cpp
*作 者:刘亚
*完成日期:2016年 5月 17日
*版 本 号:1.0
*
*问题描述:文件的应用
*输入描述:
*程序输出: MAX
*/
#include <iostream>
#include<fstream>
#include<cstdlib>
using namespace std;
int main()
{
int a, max=-9999;
ifstream infile("f1.dat",ios::in);
if(!infile)
{
cerr<<"open error!"<<endl;
exit(1);
}
while(infile>>a)
{
if(a>max)max=a;
}
cout<<"max="<<max<<endl;
infile.close();
return 0;
}
{
int a, max=-9999;
ifstream infile("f1.dat",ios::in);
if(!infile)
{
cerr<<"open error!"<<endl;
exit(1);
}
while(infile>>a)
{
if(a>max)max=a;
}
cout<<"max="<<max<<endl;
infile.close();
return 0;
}