fortran - 逻辑运算符 '.or.' 的操作数 在(!)是逻辑(4)/字符(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)
它给了我以下错误:
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 LOGICAL(4)/CHARACTER(1)
解决方案
您正在使用以下语句:
if(fig == 't' .or. 'T')
这应该是:
if(fig == 't' .or. fig == 'T')
推荐阅读
- awk - sed 用于插入 x 位直到 y 位
- flutter - 如何为 Flutter Web 应用设置标题和图标?
- reactjs - 来自异步方法的渲染数据未定义
- python - 在 Tensorflow/Keras 中没有参数共享的 LSTM
- sparql - SPARQL:每个命名图中的语句数
- php - 从搜索查询中获取唯一值以填充搜索过滤器选项
- firebase - 限制作者的权限不在 Firestore 规则中工作
- sql - SQL查询可预订房间
- tmux - tmux 状态栏中的 zscroll 文本
- javascript - 纯 JavaScript:获取 body 的子级返回 undefined