Fortran- int計算後變成float?

匿 匿名 605 次瀏覽 0 個回答

寫個簡單的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 個回答

還沒有人回答,你知道答案嗎?

我要回答

登入會員後即可回答問題。

免費註冊