Advertisement
Tim051098

Untitled

Mar 22nd, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.43 KB | None | 0 0
  1. subroutine Input
  2. common /data/ xmin, xmax, xi, ymin, ymax, yi
  3. open(1,file='lab2.txt',status='old',err=1)
  4. read(1,*,err=2,end=3) xmin, xmax, xi, ymin, ymax, yi
  5. goto 4
  6. 1 print *, 'Error, can not open file'
  7. goto 5
  8. 2 print *, 'Error, can not read file'
  9. goto 5
  10. 3 print *, 'Error, end of the file'
  11. goto 5
  12. 6 print *, 'Error, min>max (i>0)'
  13. 7 print *, 'Error, min<max (i<0)'
  14. 4 if (xi .gt. 0) then
  15. if (xmin .ge. xmax) goto 6
  16. else
  17. if (xmin .le. xmax) goto 7
  18. endif
  19. if (yi .gt. 0) then
  20. if (ymin .ge. ymax) goto 6
  21. else
  22. if (ymin .le. ymax) goto 7
  23. endif
  24. 5 close(1,status='keep')
  25. end
  26. ******************************************************************
  27. subroutine Size
  28. common/data/xmin,xmax,xi,ymin,ymax,yi
  29. common/tabl/n,m
  30. a=(xmax-xmin)/xi
  31. n=nint(a)
  32. if (n.lt.a) n=n+1
  33.  
  34. b=(ymax-ymin)/yi
  35. m=nint(b)
  36. if (m.lt.b)m=m+1
  37. ! n=n+1 !for arg
  38. ! m=m+1 !for arg
  39. print *,n,m
  40. end
  41. *******************************************************************
  42. subroutine Table
  43. common/data/xmin,xmax,xi,ymin,ymax,yi
  44. common/tabl/n,m
  45. ! integer f
  46. ! f=0
  47. pi = 3.14159265
  48. call size
  49. open(2,file='output.txt',status='old',err=8)
  50. goto 9
  51. 8 print *, 'Error, can not open file'
  52. *-----------------shapka-----------------*
  53. 9 write (2,40) 'x\y'
  54. ty=ymin-yi
  55. do i=1,m+1,1
  56. if (ty+yi .ge. ymax)then
  57. write (2,30) ymax
  58. else
  59. ty=ty+yi
  60. write (2,20) ty
  61. endif
  62. enddo
  63. write(2,80) ' '
  64.  
  65. *----------------------------------------*
  66. tx=xmin-xi
  67. do j=1,n+1,1
  68. tx=tx+xi
  69. if(tx.gt.xmax) then
  70. tx=xmax
  71. endif
  72. do while (tx .gt. 360)
  73. tx=tx-360
  74. enddo
  75. !l=tx/180
  76. !ttx=tx/180
  77. write (2,50) tx
  78. ty=ymin-yi
  79. do i=1,m,1
  80. ty=ty+yi
  81. if ((ty.eq.90).or.(ty.eq.270)) then
  82. write(2,60) 'err'
  83. else
  84. do while (ty .gt. 360)
  85. ty=ty-360
  86. enddo
  87. r1=sin(tx*pi/180)
  88. r2=cos(ty*pi/180)
  89. res=r1/r2
  90. write (2,20) res
  91. endif
  92. enddo
  93. ty=ymax
  94. if ((ty.eq.90).or.(ty.eq.270)) then
  95. write(2,70) 'err'
  96. else
  97. do while (ty .gt. 360)
  98. ty=ty-360
  99. enddo
  100. r1=sin(tx*pi/180)
  101. r2=cos(ty*pi/180)
  102. res=r1/r2
  103. write (2,30) res
  104. endif
  105. enddo
  106. !
  107. !
  108. 20 format (F10.4, ' | ' \)
  109. 30 format (F10.4, ' | ') !C perevodom
  110. 50 format (F11.4, ' || ' \)
  111. !
  112. 40 format (A11, ' || ' \)
  113. 60 format (A10, ' | ' \)
  114. 70 format (A10, ' | ')
  115. 80 format (A10) !dlya perevoda na nov. stroky
  116. !
  117. close(2)
  118. end
  119. ****************************************************************
  120. program main
  121. common /data/ xmin, xmax, xi, ymin, ymax, yi
  122. call Input
  123. call Table
  124. !print *, xmin, xmax, xi, ymin, ymax, yi
  125. pause
  126. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement