ex0508.f90

来自「fortran 95书的源程序全集」· F90 代码 · 共 37 行

F90
37
字号
program ex0508
implicit none
  real x,y
  integer ans
  
  write(*,*) "Input (x,y)"
  read(*,*) x,y

  if ( x>0 ) then
    if ( y>0 ) then ! x>0,y>0
	  ans=1
	else if ( y<0 ) then ! x>0, y<0
	  ans=4
	else ! x>0, y=0
      ans=0
	end if
  else if ( x<0 ) then
    if ( y>0 ) then ! x<0, y>0
	  ans=2
	else if ( y<0 ) then ! x<0, y<0
      ans=3
	else ! x<0, y=0
	  ans=0
	end if
  else ! x=0, y=任意数
    ans=0
  end if

  if ( ans/=0 ) then ! ans不为0时, 代表有解
	write(*,"('第',I1,'象限')") ans
  else
    write(*,*) "落在轴上"
  end if 

  stop
end

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?