编程介的小学生 2019-01-09 13:08 采纳率: 20.5%
浏览 260
已采纳

重新定义的加号和减法的运算,采用C程序设计的技术怎么实现?

Problem Description
Professor Octastichs has invented a new programming language, Smeech. An expression in Smeech may be a positive or negative integer, or may be of the form (p e1 e2) where p is a real number between 0 and 1 (inclusive) and e1 and e2 are Smeech expressions. The value represented by a Smeech expression is as follows:
1) An integer represents itself
2) With probability p, (p e1 e2) represents x+y where x is the value of e1 and y is the value of e2; otherwise it represents x-y.
Given a Smeech expression, what is its expected value?

Input
Input consists of several Smeech expressions, one per line, followed by a line containing ().

Output
For each expression, output its expected value to two decimal places.

Sample Input
7
(.5 3 9)
()

Sample Output
7.00
3.00

  • 写回答

1条回答 默认 最新

  • threenewbee 2019-12-29 00:34
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 GDI处理通道视频时总是带有白色锯齿
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大
  • ¥15 Revit2020下载问题
  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大
  • ¥15 单片机无法进入HAL_TIM_PWM_PulseFinishedCallback回调函数