Advertisement
Guest User

Untitled

a guest
Feb 28th, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.       function f(x, y)
  2.       common /const/ pi
  3.       f = abs(cos(x*pi/180)/sin(y*pi/180))
  4.       end
  5.      
  6.       program main
  7.       common /const/ pi
  8.       common /values/ x1, x2, y1, y2, hx, hy
  9.       pi = 3.1415927
  10.      
  11.       call input
  12.       call output
  13.       write (*,*) 'OK'
  14.      
  15.       pause
  16.       end
  17.  
  18.       subroutine input
  19.       character*20 msg
  20.       common /const/ pi
  21.       common /values/ x1, x2, y1, y2, hx, hy
  22.       open(1, file = 'input.txt')
  23.       read(1,*) x1, x2, hx
  24.       read(1,*) y1, y2, hy
  25.      
  26.       if (((x2-x1).GT.0.AND.hx.LT.0).OR.((x2-x1).LT.0.AND.hx.GT.0)) then
  27.       msg = 'bad input data for x'
  28.       call exeption(msg)
  29.       end if
  30.       if (((y2-y1).GT.0.AND.hy.LT.0).OR.((y2-y1).LT.0.AND.hy.GT.0)) then
  31.       msg = 'bad input data for y'
  32.       call exeption(msg)
  33.       end if      
  34.       end
  35.      
  36.       subroutine output
  37.       logical bm, bn
  38.       common /const/ pi
  39.       common /values/ x1, x2, y1, y2, hx, hy
  40.      
  41.  100  format (E10.4, '   ' \)
  42.  101  format (A11, '    ' \)
  43.  102  format (E11.4, '    ' \)
  44.  103  format (A10, '   ' \)
  45.  104  format (A10)
  46.  
  47.       open(2, file = 'output.txt')
  48.  
  49.       a = abs((x2-x1)/hx)
  50.       b = abs((y2-y1)/hy)
  51.      
  52.       m = a + 1
  53.       n = b + 1
  54.      
  55.       bm = (a - int(a)).NE.0
  56.       bn = (b - int(b)).NE.0
  57.      
  58.       if (bm) m = m + 1
  59.       if (bn) n = n + 1
  60.      
  61.       write(2, 101) 'y\x'
  62.      
  63.       do x = x1,x2,hx
  64.         write(2, 100) x
  65.       end do
  66.      
  67.       if (bm) write(2, 100) x2
  68.      
  69.       write(2, 104)
  70.       write(2, 104)
  71.      
  72.       do y = y1,y2,hy
  73.         write(2, 102) y
  74.         do x = x1,x2,hx
  75.             if (sin(y*pi/180).NE.sin(0.0)) then
  76.                 write(2, 100) f(x, y)
  77.             else
  78.                 write(2, 103) '+inf'
  79.             end if
  80.         end do
  81.         if (bm) write(2, 100) f(x2, y)
  82.         write (2, 104)
  83.       end do
  84.      
  85.       if (bn) then
  86.         write(2, 102) y*180/pi
  87.         do x = x1,x2,hx
  88.             if (sin(y*pi/180).NE.sin(0.0)) then
  89.                 write(2, 100) f(x, y2)
  90.             else
  91.                 write(2, 103) '+inf'
  92.             end if
  93.         end do
  94.         if (bm) write(2, 100) f(x2, y2)
  95.         write (2, 104)
  96.       end if
  97.      
  98.       close(2)
  99.       end
  100.      
  101.       subroutine exeption(message)
  102.       character*20 message
  103.       print *, message
  104.       pause
  105.       stop
  106.       end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement