Program www_fcode_cn
Implicit None
integer :: a
read(*,*) a
write(*,*) getDecimalismSum(a)
contains
Integer Function getDecimalismSum(x) result(s)
Integer , intent(IN) :: x
integer :: t
t = abs(x)
s = 0
do
s = s + mod(t,10)
if( t < 10 ) exit
t = t/10
end do
End Function getDecimalismSum
End Program www_fcode_cn
楚香饭 发表于 2020-4-16 09:02
一直除10,直到小于10为止
[mw_shl_code=fortran,true]Program www_fcode_cn
欢迎光临 Fortran Coder (http://bbs.fcode.cn/) | Powered by Discuz! X3.2 |