program main implicit none integer :: i,j,n,prod,m integer, allocatable :: a(:,:) real*8 :: h,integ,b1,b2,x,f,fmax,xmax !1) open(10,file='input') do read(10,*) n if (n.gt.1) exit enddo allocate(a(n,n)) do i=1,n do j=1,n read(10,*) a(i,j) enddo enddo close(10) !2) call do_op(n,a,prod) !3) write(*,*) 'Number of points' read(*,*) m b1=-8.d0 b2=8.d0 h=(b2-b1)/dble(m) if (prod.gt.5.d0) then integ=f(b1)+f(b2) integ=0.5d0*integ do i=1,m-1 x=b1+i*h integ=integ+f(x) enddo integ=integ*h else fmax=f(b1) write(*,*) 'primo',fmax do i=1,m x=b1+i*h if (f(x).gt.fmax) then fmax=f(x) xmax=x write(*,*) xmax,fmax endif enddo endif !4) write(*,*) 'The product is' write(*,101) prod if (prod.gt.5.d0) then write(*,*) 'Value of the integral' write(*,100) integ else write(*,*) 'Max value of f' write(*,100) fmax write(*,*) xmax endif 100 format(F10.3) 101 format(I5) deallocate(a) stop end program real*8 function f(x) implicit none real*8, intent(in) :: x f = exp(-0.1d0*x**2) return end function subroutine do_op(n,a,res) implicit none integer, intent(in) :: n integer, intent(in) :: a(n,n) integer, intent(out) :: res integer :: itmp,i,j res=1 do i=1,n do j=1,n itmp=i+j if (mod(itmp,2).ne.0) then res=res*a(i,j) endif enddo enddo return end subroutine