C:\Users\ASUS\Desktop\聚宝盆\颗粒布置.png
我是初学者,想计算任意第i行第j列圆盘中心坐标,即D(i,j),半径假设0.5,偶数行有11列,奇数行只有10列,可能问题出在数组上,求大神不吝赐教,万分感谢!
program zuobiao1
implicit none
integer(4) ,parameter :: A = 11
!integer(4) ,parameter :: B = 11
integer :: D_0(3,A,B)
integer,dimension(3) :: D(i,j)
D(i,j) = (/D_0(1,i,j),D_0(2,i,j),D_0(3,i,j)/)
!integer(4) ,parameter :: C = 10
!common A,B,C
integer :: s !方向赋值
integer :: i !行号赋值
integer :: j !列号赋值
real(4) :: X(3,A,B)
do s = 1,3
!s = s+1
do i = 1,A
!i = i+1
if (mod(i,2) == 0) then
do j = 1,10
!j = j+1
X(1,i,j) = j - 0.5
X(2,i,j) = (i - 1)*0.866
X(3,i,j) = 0
if (j>10) exit
D_0(1,i,j) = X(1,i,j)
D_0(2,i,j) = X(2,i,j)
D_0(3,i,j) = X(3,i,j)
end do
else
do j = 1,11
!j = j+1
X(1,i,j) = j - 1
X(2,i,j) = (i - 1)*0.866
X(3,i,j) = 0
D_0(1,i,j) = X(1,i,j)
D_0(2,i,j) = X(2,i,j)
D_0(3,i,j) = X(3,i,j)
end do
end if
end do
!X(3,i,j) = 0
end do
write(*,*) "行号:"
read(*,*) i
write(*,*) "列号:"
read(*,*) j
write(*,*) X(1,i,j)
write(*,*) X(2,i,j)
write(*,*) X(3,i,j)
write(*,*) D(i,j)
stop
end program |