#include <iostream> #include <fstream>using namespace Std;int main () { int a,b=-100000,c; cin>>c; int i; Ifstream infile ("F1.dat", ios::in); for (i=0;i<c;i++) { infile>>a; if (a>b) b=a; } cout<< "max number:" <<b<<endl; Infile.close (); return 0;}
Description
In file F1.dat, n is provided (n is a very large number that is not required in the program) and a positive integer.
Please compile the program. The maximum value in the number of top N (n<n) in the output file.
The first 10 data in F1.dat, such as the following, are in the process of debugging a program. A self-built F1.dat file with a content of 10 integers.
52
69
21st
29
65
79
72
27
35
24
Input
The integer n, which represents the maximum value of the output, is the maximum number of top n in the F1.dat file
Output
The maximum value of the first n number in the F1.dat file. Because F1.dat is already given in the title, the maximum value depends on the file content.
The data given in the description section of the title: input n is 5 o'clock, output "Max number:69". Input n is 8 o'clock, output "Max number:79".
Sample Input5Sample OutputMax number:69
Copyright notice: This article blog original articles, blogs, without consent, may not be reproduced.
C + + Read text file