习题一、设有算术表达式a+b*c-(c*b+a-e),要求: (1)写出该表达式的四元组中间代码。 (2)写出该表达式的三元式。 习题二、写出赋值语句a:=a*-(b+c) (1) 三元式 (2)假定a的类型为real,c和b的类型为integer 习题三、翻译下面的控制语句: if (a<b) and (c>d) then x:=y+z else x:=y-z
时间: 2024-02-14 10:35:41 浏览: 172
很好,您的问题已经收到了!请看下面的回答:
习题一:
(1)四元组中间代码:
1. t1 = b * c
2. t2 = a + t1
3. t3 = c * b
4. t4 = t3 + a
5. t5 = t4 - e
6. result = t2 - t5
(2)三元式:
1. (*, b, c, t1)
2. (+, a, t1, t2)
3. (*, c, b, t3)
4. (+, t3, a, t4)
5. (-, t4, e, t5)
6. (-, t2, t5, result)
习题二:
(1)三元式:
1. (+, b, c, t1)
2. (-, 0, t1, t2)
3. (*, a, t2, t3)
4. (:=, t3, _, a)
(2)类型转换:
1. (+, b, c, t1)
2. (conv, t1, int2real, t2)
3. (-, 0.0, t2, t3)
4. (*, a, t3, t4)
5. (:=, t4, _, a)
习题三:
if (a < b) and (c > d) then
x = y + z
else
x = y - z
相关问题
sdut-入门-1 A+B for Input-Output Practice(I)
好的,这是一道简单的输入输出练习题,题目描述如下:
给定两个整数 A 和 B,输出 A+B 的值。
输入格式:
共一行,包括两个整数 A 和 B。
输出格式:
共一行,包括一个整数,表示 A+B 的值。
样例输入:
3 4
样例输出:
7
你可以使用以下代码来实现:
```python
a, b = map(int, input().split())
print(a + b)
```
# 打印所有的水仙花数字,这个一个三位数abc # 并且满足条件abc==a**3+b**3+c**3
好的,这是一个简单的Python练习题,可以用循环和条件语句来解决。以下是示例代码:
```python
for num in range(100, 1000):
# 分离出百位、十位和个位数字
digit_1 = num // 100
digit_2 = (num // 10) % 10
digit_3 = num % 10
# 计算立方和
sum_of_cubes = digit_1 ** 3 + digit_2 ** 3 + digit_3 ** 3
# 判断是否为水仙花数字
if num == sum_of_cubes:
print(num)
```
这段代码会输出所有的水仙花数字,即153、370、371和407。
阅读全文
相关推荐
![application/pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![doc](https://img-home.csdnimg.cn/images/20241231044833.png)
![docx](https://img-home.csdnimg.cn/images/20241231044901.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)