fork download
  1. ! 宣告區域(declaration section)
  2. program disxy
  3.  
  4. ! 這個程式在求座落在XY平面上 P, Q 兩點距離
  5. implicit none
  6.  
  7. ! Variables- 宣告 執行區域內所有用到(出現)的變數/陣列的 資料型態
  8. real :: x1, y1 ! P點座標
  9. real :: x2, y2 ! Q點座標
  10. real :: temp ! 暫存計算過程中之資料
  11. real :: distance ! P, Q 兩點距離
  12.  
  13. ! 執行區域(execution section)
  14.  
  15. ! 讀入 P, Q 兩點座標
  16. print *, '輸入P點 x, y 座標'
  17. read(*,*) x1, y1
  18. print *, '輸入Q點 x, y 座標'
  19. read(*,*) x2, y2
  20.  
  21. ! 計算 P, Q 兩點距離
  22. temp = (x1 - x2)**2 + (y1 - y2)**2
  23. distance = sqrt(temp)
  24.  
  25. ! 輸出(列印出) P, Q 兩點座標 和 距離
  26. write(*,*)'P點 x, y 座標 :', x1, y1
  27. write(*,*)'Q點 x, y 座標 :', x2, y2
  28. write(*,*)'P, Q 兩點距離 :', distance
  29.  
  30. ! 結束區域(termination section)
  31. end program disxy
Runtime error #stdin #stdout #stderr 0s 3968KB
stdin
Standard input is empty
stdout
 輸入P點 x, y 座標
stderr
At line 17 of file prog.f95 (unit = 5, file = 'stdin')
Fortran runtime error: End of file