贊助廠商

娛樂城推薦

首頁

刊登資訊

  • 刊登者:匿名
  • 時間:2021-06-04 03:40:04

尚未解答Fortran- int計算後變成float?

Fortran- int計算後變成float?

寫個簡單的int四則運算 結果竟變成float
附上程式碼 請各位解惑 如何自行設定字元數並輸出int


--------------------程式碼--------------------
program cal_int

integer::count1,count2
integer::cost1,cost2,cost
integer::earn1,earn2,earn

count1=1
count2=1

cost1=400
earn1=50
cost2=40
earn2=5

cost=count1*cost1+count2*cost2
earn=count1*earn1+count2*earn2

write(*,*)cost,earn
write(*,'(2i11)')cost,earn
write(*,'(2f11.11)')cost,earn

end program
----------------------------------------------


!結果第一行
! 440 55 (輸出兩個整數,空白字元數量僅示意用)
!結果第二行
! 1234567890 1234567890 (輸出兩個i10亂碼,各占11個字元)
!結果第三行
! 440. 55. (輸出兩個浮點數)

--

0個答案 Fortran- int計算後變成float?

其他問題

友站連結