2个回答
展开全部
支持楼上,这就是考试与实际应用的差别。
program main
implicit none
integer :: i, j
real :: temp, amax, amin
real :: a(5) = (/3.,4.,5.,4.,3./)
amax=a(1)
amin=a(1)
do i=2,5
if(a(i).gt.amax) amax=a(i)
if(a(i).lt.amax) amin=a(i)
end do
write( * , * ) 'max=', amax
write( * , * ) 'min=', amin
!一下为由大到小的排序
do i=1,4
do j=i+1,5
if(a(j).gt.a(i))then
temp=a(i)
a(i)=a(j)
a(j)=temp
end if
end do
end do
write(*,*)a
end program main
program main
implicit none
integer :: i, j
real :: temp, amax, amin
real :: a(5) = (/3.,4.,5.,4.,3./)
amax=a(1)
amin=a(1)
do i=2,5
if(a(i).gt.amax) amax=a(i)
if(a(i).lt.amax) amin=a(i)
end do
write( * , * ) 'max=', amax
write( * , * ) 'min=', amin
!一下为由大到小的排序
do i=1,4
do j=i+1,5
if(a(j).gt.a(i))then
temp=a(i)
a(i)=a(j)
a(j)=temp
end if
end do
end do
write(*,*)a
end program main
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询