博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
c++读取文本文件
阅读量:7169 次
发布时间:2019-06-29

本文共 668 字,大约阅读时间需要 2 分钟。

#include
#include
using namespace std;int main(){ int a,b=-100000,c; cin>>c; int i; ifstream infile("f1.dat",ios::in); for(i=0;i
>a; if(a>b) b=a; } cout<<"max number: "<
<

Description

在文件f1.dat中,提供了N(N是一个非常大的数,程序中不须要用到)个正整数。

请编程序。输出文件里前n(n<N)个数中的最大值。

f1.dat中的前10个数据例如以下,请在调试程序时。自建f1.dat文件,其内容是10个整数。
52
69
21
29
65
79
72
27
35
24

Input

整数n,代表输出的最大值是f1.dat文件里前n个数中的最大值

Output

f1.dat文件里前n个数中的最大值。因为f1.dat已经在题目中给定,这个最大值取决于文件内容。

就题目描写叙述部分给出的数据:输入n为5时,输出“max number: 69”。输入n为8时,输出“max number: 79”。

Sample Input

5

Sample Output

max number: 69

版权声明:本文博客原创文章,博客,未经同意,不得转载。

你可能感兴趣的文章