首页 > 解决方案 > IF 语句程序

问题描述

我有一个问题。我必须为我的计算器编写一个程序,但我不知道该怎么做。它使用一种形式的 QBASIC 语言。

我的声明是:

IF (y>0 and x>0) then it should calculate n:=ATAN(y/x);
IF (y<0 and x<0) then it should calculate n:=ATAN(y/x)+180;
IF (y>0 and x<0) then it should calculate n:=ATAN(y/x)+180;
IF (y<0 and x>0) then it should calculate n:=ATAN(y/x)+360;

我想我只能使用 (IF, ELSE, THEN)

标签: if-statementnestedexpressionqbasic

解决方案


你的代码是

 cls
input x 
input y
if y>0 and x>0 then 
n=ATAN(y/x) 
else if y<0 and x<0 then 
n= ATAN(y/x)+ 180 
else if y>0 and x<0 then 
n=ATAN(y/x)+180 
else if y<0 and x>0 then 
n= ATAN(y/x)+360
endif
end

推荐阅读