报错提示:
IVF2011
[Fortran] 纯文本查看 复制代码 !select case 语句范例
program test001
implicit none
!变量申明
real::result
real::plus,minus
integer::guess
integer::i
!可执行段
print*,'what is the number?'
print*,'play the game?[0-exit 1-play]'
read(*,*)i
!初始化
do while(0/=i)
call random_number(result)
call random_number(plus)
call random_number(minus)
result=100.0*result+1.0
plus=10.0*plus
minus=20.0*minus
write(*,'(1x,a,i3,",",i3,a)')'the number is in the range of[', && int(result)-int(minus),int(result)+int(plus)),']'
print*,'your guess is?'
!循环猜测
do i=1,5
read(*,*)guess
select case(int(result))==guess)
case(.true.)
print*,'congratulation! you get the number!'
write(*,'(1x,"and your score is:",i3)') 6-i
exit
case default
write(*,*)'so sad,you almost get the number'
if(5==i) then
print*,'sorry,you have lost your five times!'
write(*,'(1x,a,i3)'),"and the right number is:',int(result)
else
print*,'your new guess is?'
endif
end select
enddo
print*,'continue the game?[0-exit 1-continue]'
read(*,*)i
enddo
print*,'thanks for playing'
end program test001 |