fortran在线求解(在线求解)

img

你好,代码供参考,好久没碰到fortran的题目啦

program test
implicit none
real(8):: h     ! height
real(8):: G     ! gravity constant
real(8):: grav  ! gravity acceleration
real(8):: M     ! mass of the earth
real(8):: R     ! radius of the earth
integer(4):: I
G = 6.672d-11
M = 5.98d24
R = 6371d3
write(*,100)
100 format(T1,'Height(km)',T15,'Gravity_Acceleration(m/s^2)')
do I = 0, 40000, 500
h = I*1d3
grav = -G*M/(R+h)**2
write(*,101)I, grav
101 format(T1,I8,T15,F12.8)
enddo
end

打印出来表格如下

Height(km)    Gravity_Acceleration(m/s^2)
       0       -9.82973956
     500       -8.45117947
    1000       -7.34352198
    1500       -6.44017097
    2000       -5.69380432
    2500       -5.07004791
    3000       -4.54344574
    3500       -4.09482096
    4000       -3.70950493
    4500       -3.37612276
    5000       -3.08574407
    5500       -2.83127863
    6000       -2.60703948
    6500       -2.40842231
    7000       -2.23166727
    7500       -2.07367971
    8000       -1.93189377
    8500       -1.80416758
    9000       -1.68870184
    9500       -1.58397615
   10000       -1.48869868
   10500       -1.40176616
   11000       -1.32223175
   11500       -1.24927921
   12000       -1.18220183
   12500       -1.12038528
   13000       -1.06329345
   13500       -1.01045686
   14000       -0.96146289
   14500       -0.91594776
   15000       -0.87358976
   15500       -0.83410349
   16000       -0.79723513
   16500       -0.76275825
   17000       -0.73047041
   17500       -0.70019015
   18000       -0.67175440
   18500       -0.64501635
   19000       -0.61984350
   19500       -0.59611602
   20000       -0.57372533
   20500       -0.55257288
   21000       -0.53256901
   21500       -0.51363205
   22000       -0.49568746
   22500       -0.47866709
   23000       -0.46250854
   23500       -0.44715459
   24000       -0.43255271
   24500       -0.41865456
   25000       -0.40541564
   25500       -0.39279490
   26000       -0.38075445
   26500       -0.36925925
   27000       -0.35827688
   27500       -0.34777726
   28000       -0.33773252
   28500       -0.32811676
   29000       -0.31890589
   29500       -0.31007750
   30000       -0.30161070
   30500       -0.29348600
   31000       -0.28568523
   31500       -0.27819138
   32000       -0.27098858
   32500       -0.26406193
   33000       -0.25739750
   33500       -0.25098222
   34000       -0.24480383
   34500       -0.23885080
   35000       -0.23311230
   35500       -0.22757815
   36000       -0.22223875
   36500       -0.21708509
   37000       -0.21210864
   37500       -0.20730136
   38000       -0.20265568
   38500       -0.19816444
   39000       -0.19382086
   39500       -0.18961854
   40000       -0.18555143

如有帮助,还望题主给个宝贵的采纳支持一下答主答题哟,谢谢啦