在文件中直接读取出数字,然后求得最大值。非常简单的程序
#include<iostream>
using namespace std;
int main(){
freopen("test.txt","r",stdin); //默认在本工程文件里的test.txt
int n,max = 0;
while(cin >> n){
if(n > max)
max = n;
}
cout<<max<<endl;
return 0;
}
在文件中直接读取出数字,然后求得最大值。非常简单的程序
#include<iostream>
using namespace std;
int main(){
freopen("test.txt","r",stdin); //默认在本工程文件里的test.txt
int n,max = 0;
while(cin >> n){
if(n > max)
max = n;
}
cout<<max<<endl;
return 0;
}