fortran if 的使用program maxareal a(4,4),amaxread*,aamax=a(1,1)do i=1,4if (a(i,1).gt.amax) amax=a(i,1)if (a(i,4).gt.amax) amax=a(i,4)enddodo j=1,4if (a(1,j).gt.amax) amax=a(1,j)if (a(4,j).gt.amax) amax=a(4,j)enddo end这个程序是对的,但是
来源:学生作业帮助网 编辑:作业帮 时间:2024/09/06 21:07:58
![fortran if 的使用program maxareal a(4,4),amaxread*,aamax=a(1,1)do i=1,4if (a(i,1).gt.amax) amax=a(i,1)if (a(i,4).gt.amax) amax=a(i,4)enddodo j=1,4if (a(1,j).gt.amax) amax=a(1,j)if (a(4,j).gt.amax) amax=a(4,j)enddo end这个程序是对的,但是](/uploads/image/z/4647285-45-5.jpg?t=fortran+if+%E7%9A%84%E4%BD%BF%E7%94%A8program+maxareal+a%284%2C4%29%2Camaxread%2A%2Caamax%3Da%281%2C1%29do+i%3D1%2C4if+%28a%28i%2C1%29.gt.amax%29+amax%3Da%28i%2C1%29if+%28a%28i%2C4%29.gt.amax%29+amax%3Da%28i%2C4%29enddodo+j%3D1%2C4if+%28a%281%2Cj%29.gt.amax%29+amax%3Da%281%2Cj%29if+%28a%284%2Cj%29.gt.amax%29+amax%3Da%284%2Cj%29enddo+end%E8%BF%99%E4%B8%AA%E7%A8%8B%E5%BA%8F%E6%98%AF%E5%AF%B9%E7%9A%84%2C%E4%BD%86%E6%98%AF)
fortran if 的使用program maxareal a(4,4),amaxread*,aamax=a(1,1)do i=1,4if (a(i,1).gt.amax) amax=a(i,1)if (a(i,4).gt.amax) amax=a(i,4)enddodo j=1,4if (a(1,j).gt.amax) amax=a(1,j)if (a(4,j).gt.amax) amax=a(4,j)enddo end这个程序是对的,但是
fortran if 的使用
program maxa
real a(4,4),amax
read*,a
amax=a(1,1)
do i=1,4
if (a(i,1).gt.amax) amax=a(i,1)
if (a(i,4).gt.amax) amax=a(i,4)
enddo
do j=1,4
if (a(1,j).gt.amax) amax=a(1,j)
if (a(4,j).gt.amax) amax=a(4,j)
enddo
end
这个程序是对的,但是为什么一旦我加入 endif 和 then 的时候 反而错了
fortran if 的使用program maxareal a(4,4),amaxread*,aamax=a(1,1)do i=1,4if (a(i,1).gt.amax) amax=a(i,1)if (a(i,4).gt.amax) amax=a(i,4)enddodo j=1,4if (a(1,j).gt.amax) amax=a(1,j)if (a(4,j).gt.amax) amax=a(4,j)enddo end这个程序是对的,但是
语法就是这样的.
比如:
if (a(i,1).gt.amax) amax=a(i,1)
是对的.
如果换成另一种形式,写成
if (a(i,1) then
.gt.amax) amax=a(i,1)
endif.
也是对的.