怎样用fortran求两个数的最大公因数

秋天以后 1年前 已收到1个回答 举报

靠我没有名字 幼苗

共回答了24个问题采纳率:87.5% 举报

program main
!辗转相除法
integer m,n
common m,n
print*,'Please input two positive integers:'
read(*,*) m,n
call Euclid(m,n)
endprogram
subroutine Euclid(m,n)
integer r
do while(n.ne.0)
 r = mod(m,n)
 m = n
 n = r
enddo
print*,'Their greatest common divisor is', m
endsubroutine

1年前

1
可能相似的问题
Copyright © 2024 YULUCN.COM - 雨露学习互助 - 16 q. 0.118 s. - webmaster@yulucn.com