!
implicit none
integer i
do i=100,999
if (mod(i,7).eq.3) then
if (mod(i,5).eq.2) then
if (mod(i,3).eq.1) then
print *, 'i=',i
end if
end if
end if
end do
stop
end
(2)
!
implicit none
integer f,i,j,n,s
n=0
s=0
do i=100,200
if (mod(i,10).eq.3) then
f=0
do j=2,i-1
if (mod(i,j).eq.0) then
f=f+1
end if
end do
if (f.eq.0) then
print *, 'i=',i
n=n+1
s=s+i
end if
end if
end do
print *, 'n=',n
print *, 'sum=',s
stop
end
(3)
!
implicit none
integer i,j,k,f,n
n=0
do i=5,99,5
do j=1,99-i
k=100-i-j
f=i/5+j+3*k
if(f.eq.100) then
n=n+1
print *, 'i=',i,'//','j=',j,'//','k=',k
end if
end do
end do
print *, 'n=',n
stop
end
第3题里i是小马,j是中马,k是大马。
你好同学,已经做好了。
program Console3implicit none
integer::a(10),N=10,i,sum=0,ct=0
a=(/1,2,3,4,5,6,7,8,9,10/)
do i=1,N
if(mod(a(i),2)==1)then
ct=ct+1
sum=sum+a(i)
endif
enddo
write(*,*)"奇数总和sum=",sum
write(*,*)"奇数个数ct=",ct
end program Console3
program Fibonacciinteger i,j,f,k,count,boarder
boarder=1e7
i=1
j=0
count=0
do while (.true.)
f=i+j
if(f>boarder) exit
i=j
j=f
count=count+1
end do
write(*,"(A12,I8)")"The max is: ",j
write(*,"(A32,I4)")"The number of the Fibonacci is: ",count
end program
!上面程序中,j输出的就是最大值了,count就是输出的有几个,呵呵,boarder里是你设置的那个上限。所以最大值是:9227465,个数一共是35个
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)