小编Vis*_*n C的帖子

逻辑运算符'.or.'的操作数 at(!)是逻辑(4)/ CHARACTER(1)

我有以下代码:

print*,"type s for a square and type t for a triangle"
read*,fig
if(fig =='t' .or. 'T') then
print*,"Enter the sides of the triangle"
read*,a,b,c
area=tri(a,b,c)
print*,"The area of the triangle is",area
else if (fig=='s' .or.'S') then 
print*,"Enter the side of the square"
read*,s
area=sq(s)
Run Code Online (Sandbox Code Playgroud)

它给了我以下错误:

intro_fun.f:9:24:

  if(fig == 't' .or. 'T') then
                        1
Error: Operands of logical operator '.or.' at (1) are LOGICAL(4)/CHARACTER(1)
intro_fun.f:14:27:

  else if(fig=='s' .or. 'S') then
                           1
Error: Operands of logical operator '.or.' at (1) are …
Run Code Online (Sandbox Code Playgroud)

fortran gfortran

1
推荐指数
1
解决办法
335
查看次数

标签 统计

fortran ×1

gfortran ×1