2012-05-06 1 views
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 

두 개의 개별 조건을 평가 중이므로 각 조건에 "왼쪽"과 "오른쪽"이 필요합니다.

+0

고마워, 나는 바보 야 .-) – Sensolibertaire