select_char_1.f90

来自「用于进行gcc测试」· F90 代码 · 共 77 行

F90
77
字号
integer function char_select (s)  character(len=*), intent(in) :: s  select case(s)    case ("foo")      char_select = 1    case ("bar", "gee")      char_select = 2    case ("111", "999")      char_select = 3    case ("1024", "1900")      char_select = 4    case ("12", "17890")      char_select = 5    case default      char_select = -1  end selectend function char_selectinteger function char_select2 (s)  character(len=*), intent(in) :: s  char_select2 = -1  select case(s)    case ("foo")      char_select2 = 1    case ("bar", "gee")      char_select2 = 2    case ("111", "999")      char_select2 = 3    case ("1024", "1900")      char_select2 = 4    case ("12", "17890")      char_select2 = 5  end selectend function char_select2program test  interface    integer function char_select (s)      character(len=*), intent(in) :: s    end function char_select    integer function char_select2 (s)      character(len=*), intent(in) :: s    end function char_select2  end interface  if (char_select("foo") /= 1) call abort  if (char_select("foo ") /= 1) call abort  if (char_select("foo2 ") /= -1) call abort  if (char_select("bar") /= 2) call abort  if (char_select("gee") /= 2) call abort  if (char_select("000") /= -1) call abort  if (char_select("101") /= -1) call abort  if (char_select("109") /= -1) call abort  if (char_select("111") /= 3) call abort  if (char_select("254") /= -1) call abort  if (char_select("999") /= 3) call abort  if (char_select("9989") /= -1) call abort  if (char_select("1882") /= -1) call abort  if (char_select2("foo") /= 1) call abort  if (char_select2("foo ") /= 1) call abort  if (char_select2("foo2 ") /= -1) call abort  if (char_select2("bar") /= 2) call abort  if (char_select2("gee") /= 2) call abort  if (char_select2("000") /= -1) call abort  if (char_select2("101") /= -1) call abort  if (char_select2("109") /= -1) call abort  if (char_select2("111") /= 3) call abort  if (char_select2("254") /= -1) call abort  if (char_select2("999") /= 3) call abort  if (char_select2("9989") /= -1) call abort  if (char_select2("1882") /= -1) call abortend program test

⌨️ 快捷键说明

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