[問題] rms average的算法
小弟在找習題練fortran程式時
找到練均方根值的算法
雖然最終寫出來沒有任何錯誤,但是執行的結果卻令我相當的囧
以下是我寫的程式:......
program RMS
implicit none
INTEGER :: N= 0 !THE NUMBER OF INPUT SAMPLE
REAL :: RMS_AVG= 0 !THE RMS AVERAGE OF INPUT SAMPLE
REAL :: SUM_X2= 0 !THE SUM OF THE INPUT VALUE
REAL :: X= 0 !AN INPUT DATA VALUE
!WHILE LOOP TO READ INPUT VALUES
DO
WRITE(*,*) "ENTER THE NUMBER:"
READ(*,*) X
WRITE(*,10)
10 FORMAT(1X,F10.3,"THE NUMBER IS:, X")
IF(X < 0)EXIT
N= N + 1
SUM_X2= SUM_X2 + X**2
END DO
RMS_AVG= SQRT(SUM_X2/REAL(N))
WRITE(*,*) "THE RMS AVERAGE IS:", RMS_AVG
PAUSE
end program RMS
執行出來的結果,卻是一直不斷的按數字,無法算出rms的數值....
另外,在do迴圈中間的write無法顯示裡面的字串.....
還請各位高手指點
感激不盡!!
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 123.194.155.180
推
02/14 21:45, , 1F
02/14 21:45, 1F
→
02/14 21:54, , 2F
02/14 21:54, 2F
→
02/14 21:54, , 3F
02/14 21:54, 3F
推
02/14 21:58, , 4F
02/14 21:58, 4F
→
02/15 20:03, , 5F
02/15 20:03, 5F
→
02/15 20:04, , 6F
02/15 20:04, 6F
→
02/15 20:06, , 7F
02/15 20:06, 7F
→
02/15 20:06, , 8F
02/15 20:06, 8F
→
02/20 00:16, , 9F
02/20 00:16, 9F
Fortran 近期熱門文章
PTT數位生活區 即時熱門文章