program main
implicit none
integer::hang,lie
integer,allocatable::a(:,:),b(:,:)
integer::i,j
write(*,"(A20)")"请输入矩阵的行数"
read(*,*)hang
write(*,"(A20)")"请输入矩阵的列数"
read(*,*)lie
allocate(a(hang,lie))
allocate(b(lie,hang))
write(*,"(A30)")"请输入矩阵的各项元素"
do i=1,hang
do j=1,lie
read(*,*)a(i,j)
end do
end do
do i=1,hang
do j=1,lie
b(j,i)=a(i,j)
end do
end do
write(*,*)"该矩阵形式如下"
do i=1,hang
write(*,*)a(i,:)
end do
write(*,*)"该矩阵转置形式如下"
do j=1,lie
write(*,*)b(j,:)
end do
stop
end
fortran生成一个动态二维数组,行数和列数自定义,向数组中填入数据生成矩阵的形式,并输出这个矩阵的转置形式。
最新推荐文章于 2023-06-27 00:00:19 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)