if-statement - 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)
解决方案
你的代码是
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
推荐阅读
- c# - 以编程方式部署时,带有脚本任务的 SSIS 包不起作用
- mysql - 从数据库中删除,但过滤器除外
- powershell - Office 365 Admin 以编程方式运行(图形、REST 或 powershell)
- css - CSS 动画 - 鼠标移出时恢复
- python - 从 yaml 文件中获取变量时如何摆脱使用 exec
- selenium - 如何在 Selenium 上使用 cookie 在注销后恢复所有页面信息
- mysql - 连续时间查找最小/最大时间戳MySQL
- javascript - 似乎无法从捕捉承诺中恢复过来
- javascript - 使用 AJAX 从 XML 显示图像
- css - 将外部 div 缩小到缩放(转换)内部 div 的大小