字符错误 Fortran 90



我正在努力使用一个小程序,我找不到如何纠正一个错误。

我的程序:

program calcul
! ce programme permet d'effectuer des opérations mathématique de base
IMPLICIT NONE
REAL::x,y
character(len=1)::op
character(len=16)::op_msg
write(*,*)"entrer le type d'opération à effectuer(+,-,/,x,*)"       
read(*,*)op
write(*,*)"entrer le premier nombre de l'opération"
read(*,*)x
write(*,*)"entrer le deuxième nombre de l'opération"
read(*,*)y
if(op=="+") then
  write(*,*)x,"plus",y,"egale",x+y
    else if(op=="-")then
      write(*,*)x,"moin",y,"egale",x-y
    else if ((op==("*").or.("x")) then
      write(*,*)x,"multiplie par",y,"egale",x*y
        else if (op=="/")then
          write(*,*)x,"divise par",y,"egale",x/y
else
write(*,*)"erreur:operation incorrecte"
end if
end program calcul

错误消息:

calculette.f90:21.26:
 else if ((op==("*").or.("x")) then
                                     1
Error: Invalid character in name at (1)

知道吗?我不明白为什么"x"是无效字符?

else if ((op==("*").or.op==("x")) then

您正在评估两个不同的条件,因此每个条件都需要"左"和"右"侧。

最新更新