      program program12
C
C  more advanced illustrations of control structure 
C
C  this program reads in 3 integers and compares 
C  how separated they are
C
C  CWJ SDSU  2/3/2005
C

      implicit none

      integer i,j,k

      integer iseparation

      print*,' Enter 3 integers '
      read*,i,j,k

C........... now read in an interval of separation.......

  100 continue
      print*,' Now please give me an interval of separation '
      read*,iseparation
      if(iseparation.eq.0)then
        print*,' No fair, must be positive '
        goto 100
      endif
      if(iseparation.lt.0)then
        print*,' I will make it positive '
        iseparation = abs(iseparation)
      endif

C............ compare separation................

      if(  abs(i-j).lt. iseparation
     &   .and. abs(i-k).lt.iseparation 
     &   .and. abs(j-k).lt.iseparation )then
          print*,' All 3 separated by less than ',iseparation
      elseif (abs(i-j).lt. iseparation
     &   .and. abs(j-k).lt.iseparation )then
           print*,' 2 of 3 pairs close together '
      endif
      end      

