忠告 
1. 排版很重要,一定要做。 
2. 对于代码中大量出现的同一个常数,可以定义为 Parameter,减少今后的修改量。比如你要把 2250 改成 2230,会很麻烦。 
 
如下 
[Fortran] syntaxhighlighter_viewsource syntaxhighlighter_copycode program up
  implicit none
  Integer , parameter :: N = 2250 , S = 4
  real :: x(N),y(N),z(N)
  integer :: i , j , k , l
  integer :: a(S)
  integer :: m(N,S)
  !read the file......................................
  open(1,file='XYZ1.txt')
  do i = 1,N
    read(1,*) x(i),y(i),z(i)
  end do
  close(1)
  !........draw a ball and get 4 points..............................................
  do j = 1,N
    k = 0
    do i = 1,N
      if (j == i) cycle
      if ((x(i)-x(j))**2+(y(i)-y(j))**2+(z(i)-z(j))**2 < 1.8**2) then
        k = k + 1
        a(k) = i
        if (k == 4) then
          do l = 1,S
            m(j,l) = a(l)
            print *,m(j,l)
          end do
        end if
      end if
    end do
  end do
end program up |