1
我需要帮助理解为什么我不能编译这段代码填充变量
program test
integer,dimension(1:10) :: isquares
isquares(:) = (j**2,j=1,10)
print*,isquares
end
维隐式循环然而,这个版本是确定的:
program test
print*,(j**2,j=1,10)
end
我需要帮助理解为什么我不能编译这段代码填充变量
program test
integer,dimension(1:10) :: isquares
isquares(:) = (j**2,j=1,10)
print*,isquares
end
维隐式循环然而,这个版本是确定的:
program test
print*,(j**2,j=1,10)
end
(j**2,j=1,10)
是一个隐含的循环。对于任务,您需要先将其转换为数组:
isquares(:) = [(j**2,j=1,10)]
正确,但此功能仅在Fortran 2003版本中可用。 jsquares(:) = [(j ** 2,J = 1,10)] 错误:Fortran 2003的:[...]在(1) –
然后使用'(/(j风格数组构造** 2 ,j = 1,10)/)' –