6.4
unknown
fortran
2 years ago
1.9 kB
9
Indexable
program lab6
integer:: i,j, max_value=5, min_value=-5, seed
integer:: k1,k2,k3,n1,n2,allocate_result,n,a,b
integer, parameter:: rows=5, cols=6
integer, parameter:: r=10
real:: mas0_x(rows,cols),hav, maxel,minel
integer:: size1, mas1_x(r,r), lb,ub
integer,dimension(:,:),allocatable:: mas2_x(:,:)
integer,dimension(:,:),allocatable:: mass4(:,:)
integer, allocatable:: m1(:)
integer, allocatable:: m2(:)
allocate_result=1
print*, 'введите размер матрицы'
read(*,*) size1
allocate(mas2_x(size1,size1))
do a=1, size1
do b=1, size1
if (a==b) then
mas2_x(a,b)=0
end if
if (a==((size1+1)-b)) then
mas2_x(a,b)=0
end if
end do
end do
do a=1,size1
do b=1, size1
if ((a<b) .and. (a< size1 + 1-b)) then
mas2_x(a,b)=1
end if
end do
end do
do a=1,size1
do b=1,size1
if ((a>b) .and. ( a> size1 + 1-b)) then
mas2_x(a,b)=2
end if
end do
end do
do a=1,size1
do b=1,size1
if ((b<a) .and. ( b < size1 + 1-a)) then
mas2_x(a,b)=3
end if
end do
end do
do a=1,size1
do b=1,size1
if ((b>a) .and. (b> size1 + 1-a)) then
mas2_x(a,b)=4
end if
end do
end do
do a=1,size1
do b=1,size1
write(*,'(I2)',advance='NO') mas2_x(a,b)
end do
write(*,*) ''
end do
deallocate(mas2_x)
print*, 'введите размер матрицы'
read(*,*) k1
allocate(m1(k1))
allocate(mass4(k1,k1))
do i=1,k1
do j=1,k1
do n1=1,k1*k1
mass4(i,j)=n1
end do
mass4(i,j+1)=mass4(i,j)+m1(j)
end do
end do
do i=1,k1
do j=1,k1
write(*,'(I3)',advance='NO') mass4(i,j)
end do
write(*,*) ''
end do
deallocate(mass4)
deallocate(m1)
end program lab6
Editor is loading...