2012-05-06 10 views
1

私は小さなプログラムに苦しんでいます。私は1つの誤りを訂正する方法を見つけることができません。文字の誤り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"が無効な文字である理由を理解していませんか?

答えて

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

2つの別々の条件を評価しているため、それぞれに「左」と「右」の面が必要です。

+0

ありがとう、私はばかだよ:-) – Sensolibertaire

関連する問題