[问题] 读取档案数据并求最大最小值

楼主: ganhua (GanHuaWang)   2018-11-02 12:08:05
大家好,最近学了fortran程式,还不是很熟,这边有个小问题要请教大家,问题如下
Write a Fortran that will read an arbitrary number of non-negative real
values and find the maximum and minimum of the input data.
To test your program, input the following data from a data file (x.txt) and use IOSTAT in
read command to determine the number of data points to be processed.
Print the number of data points and the maximum and minimum you find.
97,28,66,87,15,95,45,67,76,65,73,88,69,90,63,25,47,70,63,99,61,79,10,92,36,89
前面读数据的部分我已经解决,问题是如何读进来后如何用Max和min函数来找最大最小值@@
助教有打一些提示(?)教我们怎么找
https://imgur.com/a/OdZqTLX
https://imgur.com/a/VC6vPdo
可是这是从萤幕手动输入的写法,换成数据我就不太会了,= =还希望版上大神可以帮帮
期中快要爆炸的小弟Orz
作者: rex0707 (我就是我)   2018-11-02 13:23:00
read(*,*) x 改成 read(UNIT=file_unit,*) x 就可以了吧?如果是读进来存到阵列 就用MAXVAL、MINVAL找阵列的最大、小值
作者: espresso1   2018-11-03 16:08:00
因为第一个do loop已经read到档案底了,重头read要在dowhile前先rewind(30)

Links booklink

Contact Us: admin [ a t ] ucptt.com