Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- subroutine Input
- common /data/ xmin, xmax, xi, ymin, ymax, yi
- open(1,file='lab2.txt',status='old',err=1)
- read(1,*,err=2,end=3) xmin, xmax, xi, ymin, ymax, yi
- goto 4
- 1 print *, 'Error, can not open file'
- goto 5
- 2 print *, 'Error, can not read file'
- goto 5
- 3 print *, 'Error, end of the file'
- goto 5
- 6 print *, 'Error, min>max (i>0)'
- 7 print *, 'Error, min<max (i<0)'
- 4 if (xi .gt. 0) then
- if (xmin .ge. xmax) goto 6
- else
- if (xmin .le. xmax) goto 7
- endif
- if (yi .gt. 0) then
- if (ymin .ge. ymax) goto 6
- else
- if (ymin .le. ymax) goto 7
- endif
- 5 close(1,status='keep')
- end
- ******************************************************************
- subroutine Size
- common/data/xmin,xmax,xi,ymin,ymax,yi
- common/tabl/n,m
- a=(xmax-xmin)/xi
- n=nint(a)
- if (n.lt.a) n=n+1
- b=(ymax-ymin)/yi
- m=nint(b)
- if (m.lt.b)m=m+1
- ! n=n+1 !for arg
- ! m=m+1 !for arg
- print *,n,m
- end
- *******************************************************************
- subroutine Table
- common/data/xmin,xmax,xi,ymin,ymax,yi
- common/tabl/n,m
- ! integer f
- ! f=0
- pi = 3.14159265
- call size
- open(2,file='output.txt',status='old',err=8)
- goto 9
- 8 print *, 'Error, can not open file'
- *-----------------shapka-----------------*
- 9 write (2,40) 'x\y'
- ty=ymin-yi
- do i=1,m+1,1
- if (ty+yi .ge. ymax)then
- write (2,30) ymax
- else
- ty=ty+yi
- write (2,20) ty
- endif
- enddo
- write(2,80) ' '
- *----------------------------------------*
- tx=xmin-xi
- do j=1,n+1,1
- tx=tx+xi
- if(tx.gt.xmax) then
- tx=xmax
- endif
- do while (tx .gt. 360)
- tx=tx-360
- enddo
- !l=tx/180
- !ttx=tx/180
- write (2,50) tx
- ty=ymin-yi
- do i=1,m,1
- ty=ty+yi
- if ((ty.eq.90).or.(ty.eq.270)) then
- write(2,60) 'err'
- else
- do while (ty .gt. 360)
- ty=ty-360
- enddo
- r1=sin(tx*pi/180)
- r2=cos(ty*pi/180)
- res=r1/r2
- write (2,20) res
- endif
- enddo
- ty=ymax
- if ((ty.eq.90).or.(ty.eq.270)) then
- write(2,70) 'err'
- else
- do while (ty .gt. 360)
- ty=ty-360
- enddo
- r1=sin(tx*pi/180)
- r2=cos(ty*pi/180)
- res=r1/r2
- write (2,30) res
- endif
- enddo
- !
- !
- 20 format (F10.4, ' | ' \)
- 30 format (F10.4, ' | ') !C perevodom
- 50 format (F11.4, ' || ' \)
- !
- 40 format (A11, ' || ' \)
- 60 format (A10, ' | ' \)
- 70 format (A10, ' | ')
- 80 format (A10) !dlya perevoda na nov. stroky
- !
- close(2)
- end
- ****************************************************************
- program main
- common /data/ xmin, xmax, xi, ymin, ymax, yi
- call Input
- call Table
- !print *, xmin, xmax, xi, ymin, ymax, yi
- pause
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement