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='C:\laba2\input.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'
- pause
- goto 5
- 2 print *, 'Error, can not read file'
- pause
- goto 5
- 3 print *, 'Error, end of the file'
- pause
- goto 5
- 6 print *, 'Error, incorrect data'
- pause
- goto 5
- 4 if (xmin.gt.xmax
- * .or. ymin.gt.ymax .or. ymin.lt.0 .or. ymax.lt.0 .or. yi.lt.0
- * .or. (xi.eq.0 .and. xmin.ne.xmax)
- * .or. (xi.eq.0 .and. xmin.ne.xmax)) then
- goto 6
- endif
- 5 close(1,status='keep')
- end
- ******************************************************************
- subroutine Size
- common/data/xmin,xmax,xi,ymin,ymax,yi
- common/tabl/n,m
- n=0
- m=0
- if (xmin.eq.xmax) then
- n=2
- else
- tmin=xmin
- do while (tmin .lt. xmax)
- tmin=tmin+xi
- n=n+1
- enddo
- !a=(xmax-xmin)/xi
- !n=a
- !if (n.lt.a) n=n+1
- n=n+2
- endif
- if (xmin.eq.ymax) then
- m=2
- else
- tmin=ymin
- do while (tmin .lt. ymax)
- tmin=tmin+yi
- m=m+1
- enddo
- !b=(ymax-ymin)/yi
- !m=b
- !if (m.lt.b)m=m+1
- m=m+2
- endif
- print *,n,m
- end
- *******************************************************************
- subroutine Table
- common/data/xmin,xmax,xi,ymin,ymax,yi
- common/tabl/n,m
- pi=3.14159265
- eps=0.0000003
- call size
- open(2,file='C:\laba2\output.txt',status='old',err=8)
- !open(2,file='C:\laba2\test1.txt',status='old',err=8)
- goto 9
- 8 print *, 'Error, can not open file'
- *---------------------------------------------*
- 9 write (2,40) 'x\y'
- ty=ymin-yi
- do i=2,m-1,1
- ty=ty+yi
- write (2,20) ty
- enddo
- if (ty+yi .ge. ymax) write (2,30) ymax
- do i=1,m-1,1
- write (2,90)
- enddo
- write (2,110)
- *---------------------------------------------*
- tx=xmin-xi
- do j=2,n,1
- tx=tx+xi
- do while (tx .ge. 360)
- tx=tx-360
- enddo
- write (2,50) tx
- ty=ymin-yi
- do i=2,m-1,1
- ty=ty+yi
- do while (ty .ge. 360)
- ty=ty-360
- enddo
- sin1=sin((tx+ty)*pi/180)
- if (tx-ty .lt. 0) then
- sin2=-sin((-(tx-ty))*pi/180)
- else
- sin2=sin((tx-ty)*pi/180)
- endif
- cos1=cos(tx*pi/180)
- if (abs(sin1+sin2) .lt. eps) then
- write (2,60) 'error'
- else
- if (tx.eq.90 .or. tx.eq.270) then
- res=0
- else
- res=2*cos1/(sin1+sin2)
- endif
- write (2,20) res
- endif
- enddo
- ty=ymax
- do while (ty .ge. 360)
- ty=ty-360
- enddo
- sin1=sin((tx+ty)*pi/180)
- if (tx-ty .lt. 0) then
- sin2=-sin((-(tx-ty))*pi/180)
- else
- sin2=sin((tx-ty)*pi/180)
- endif
- cos1=cos(tx*pi/180)
- if (abs(sin1+sin2) .lt. eps) then
- write (2,70) 'error'
- else
- if (tx.eq.90 .or. tx.eq.270) then
- res=0
- else
- res=2*cos1/(sin1+sin2)
- endif
- write (2,30) res
- endif
- do i=1,m-1,1
- write (2,90)
- enddo
- write (2,110)
- enddo
- 20 format (E11.4, ' | ' \)
- 30 format (E11.4, ' | ')!
- 50 format (E11.4, ' || ' \)
- 40 format (A11, ' || ' \)
- 60 format (A11, ' | ' \)
- 70 format (A11, ' | ')
- 80 format (A11)!
- 90 format ('--------------', \)
- !100 format ('-------------', \)
- 110 format ('--------------')!
- close(2)
- end
- ****************************************************************
- program main
- common /data/ xmin, xmax, xi, ymin, ymax, yi
- call Input
- call Table
- pause
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement