knrt.net
当前位置:首页 >> 3,下列FortrAn程序的功能是:从键盘输入一个正整数... >>

3,下列FortrAn程序的功能是:从键盘输入一个正整数...

参考代码 program test implicit none integer :: num, arr(5), i5,i4,i3,i2,i1 integer :: i,j,itmp print*, '输入一个五位正整数:' read(*,*) num i5 = num / 10000 i4 = (num - i5*10000)/1000 i3 = (num - i5*10000 - i4*1000)/100 i2 = (nu...

代码: program data_sum implicit none integer :: num, sum = 0 do read (*,*) num if (num .eq. -1) then exit end if if (num .gt. 0) then sum = sum + num end if end do write (*,'(a, i6)') 'sum = ', sumend program data_sum运行结果...

integer a,i,k,sumread(*,*)ak=int(a/2+0.1)sum=0do 10 i=1,kif (mod(a,i).eq.0) sum=sum+i10continueif (sum.eq.a) then write(*,*)'yes'elsewrite(*,*)'no'endifpauseend

参考代码 program test implicit none integer(8) :: num,i,all_product print*, ' Input a positive integer: ' read(*,*) num all_product = 1 do i = 1,num/2 if(mod(num,i) .eq. 0) then print*, i all_product = all_product * i end if en...

网站首页 | 网站地图
All rights reserved Powered by www.knrt.net
copyright ©right 2010-2021。
内容来自网络,如有侵犯请联系客服。zhit325@qq.com