Program www_fcode_cn
Implicit None
real :: a(9) = [1.,2.,3.,4.,5.,6.,7.,8.,9.]
write(*,*) sum( a( [1,3,9] ) ) !// 1,3,9 求和
write(*,*) sum( a(1:4) ) !// 1到4求和
write(*,*) sum( a ) - a(5) !// 除了5,其余求和
End Program www_fcode_cn
write(*,*) sum( a , mask = ( a > 3.0 ) ) !// 大于 3.0 的值参与求和
欢迎光临 Fortran Coder (http://bbs.fcode.cn/) | Powered by Discuz! X3.2 |