[問題] 讀取檔案數據並求最大最小值

作者: 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