      include 'horner.f'
      PROGRAM HOR22
c     OBLICZA WARTOSC WIELOMIANU I JEGO POCHODNEJ W x 
c     POSLUGUJE SIE PODPROGRAMEM ZEWNETRZNYM horner.f
c     CZYTA DANE (punkty do tablicowania) z PLIKU XX
      integer M,N,j,k,pyt
      real*8 a,b,c,x,R,S,RR,SS,XX
      dimension a(0:100),b(0:100),c(0:100)
      dimension RR(0:200),SS(0:200),XX(0:200)
   10 write(*,*)'PROGRAM HOR2'
      open(unit=10,file='RR')
      open(unit=11,file='SS')
      open(unit=12,file='XX')
      write(*,*)'PODAJ N - STOPIEN WIELOMIANU, M LCZBA PUNKTOW x'
      read (*,*) N,M
      write(*,*)'10 - CZYTAJ Z KLAWIATURY XX(j) I ZAPISUJ NA DYSK'
      write(*,*)'11 - ODRAZU CZYTAJ XX Z DYSKU'
      read (*,*) pyt
      if(pyt.eq.10)then
      do 11,j=0,M,1
      read (*,*) XX(j)
   11 continue
      rewind(12)
      do 12,j=0,M,1
      write(12,*) XX(j)
   12 continue
      write(*,*)'XX KONIEC'
      else
      continue
      endif
      write(*,*)'PODAWAJ a(j), j=0,1,...,N'
      do 1,j=0,N,1
      read(*,*) a(j)
    1 continue
      rewind(12)
      do 2,j=0,M,1
      read (12,*) XX(j)
    2 continue
      do 3,j=0,M,1
      call horner(N,a,b,XX(j),RR(j))
      call horner(N-1,b,c,XX(j),SS(j))
    3 continue
      rewind(10)
      do 4,j=0,M,1
      write(10,*) RR(j)
    4 continue
      rewind(11)
      do 5,j=0,M,1
      write(11,*)SS(j)
    5 continue
      write(*,*)'GOTOWE'
      write(*,*)'<ENTER>'
      read (*,*)
      write(*,*)' 0 - KONIEC'
      write(*,*)' 1 - OD POCZATKU'
      read (*,*) pyt
      if(pyt.eq.0)goto 100
      goto 10
  100 close(10)
      close(11)
      close(12)
      stop 100
      end
       
