用Fortran90编程:从一个矩阵中找出这样一个元素的位置(如果有的话),这个元素在行上最大,在列上最小。
1个回答
展开全部
program max_min
implicit none
integer::i,j,k,r,c
real,allocatable::matrix(:,:)
integer::m,n
write(*,*)"Input the dimension of the matrix."
read(*,*)m,n
allocate(matrix(m,n))
do i=1,m
do j=1,n
write(*,"('Input ('i2,i2')')")i,j
read(*,*)matrix(i,j)
end do
end do
do k=1,m
do i=1,n-1
r=1
do j=i+1,n
if(matrix(k,r)<matrix(k,j)) then
r=k
c=j
end if
end do
end do
do i=1,m
if(matrix(r,c)>matrix(i,c)) then
exit
else
write(*,"('Found one ('i2','i2')')")r,c
end if
end do
end do
end program
implicit none
integer::i,j,k,r,c
real,allocatable::matrix(:,:)
integer::m,n
write(*,*)"Input the dimension of the matrix."
read(*,*)m,n
allocate(matrix(m,n))
do i=1,m
do j=1,n
write(*,"('Input ('i2,i2')')")i,j
read(*,*)matrix(i,j)
end do
end do
do k=1,m
do i=1,n-1
r=1
do j=i+1,n
if(matrix(k,r)<matrix(k,j)) then
r=k
c=j
end if
end do
end do
do i=1,m
if(matrix(r,c)>matrix(i,c)) then
exit
else
write(*,"('Found one ('i2','i2')')")r,c
end if
end do
end do
end program
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询