首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >Fortran do循环不计算输入的变量

Fortran do循环不计算输入的变量
EN

Stack Overflow用户
提问于 2019-02-21 22:01:18
回答 2查看 299关注 0票数 0

当我只运行摄氏度的代码时,我得到了下面的代码结果:

代码语言:javascript
复制
    program temperature
! F C temperature conversion
implicit none
real :: celcius=0.0, fahrenheit=0.0

integer:: t,n
print *,'enter the number of lines'
read*, n
do n=1,n
print*,'enter the  value of t: one per line',n
read*, t
celcius=5/9*(t-32)

enddo
do n=1,n
print*, t, celcius
enddo
end program

结果

代码语言:javascript
复制
    enter the number of lines
3
 enter the  value of t: one per line           1
50
 enter the  value of t: one per line           2
20
 enter the  value of t: one per line           3
10
          10   0.00000000E+00
          10   0.00000000E+00
          10   0.00000000E+00
          10   0.00000000E+00

很明显,编译器在计算中没有选择t的值。

EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/54808847

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档