pseudocode - 您可以在伪代码的 if 语句中使用复合条件吗?
问题描述
例如这个简单的程序,它测试 3 个数字是否按升序排列
if a1<a2 then
if a2<a3 then
write "the numbers are in ascending order";
else
write "the numbers are not in ascending order";
endif
else
write "the numbers are not in ascending order;
endif
我可以用伪代码这样写吗?
if (a1<a2 and a2<a3)
write "the numbers are in ascending order";
else
write "the numbers are not in ascending order";
解决方案
是的。只要它是可以理解的并且可以很容易地转换为真正的源代码,它就可以作为伪代码。
推荐阅读
- python - 用 PyQt5 解析 JS 动态页面
- javascript - 显示结果后重置计算器显示值
- swift - 如何将 Alamofire 响应转换为字符串?
- macos - 在 macOS Mojave 上编译 Elmer FEM 会导致致命错误:找不到“string.h”文件
- reactjs - 如何用 NavigationEvents 开玩笑地测试 React Native 组件
- python - 为什么这段代码不返回元组数组?
- typescript - 打字稿:从通用接口中省略属性
- java - 在java中实现链表的麻烦
- linux - 编译内核驱动程序和 .c 文件的单个 makefile
- laravel - Laravel 6 API 不会在日志中写入错误 500