Hades_China 2021-10-15 10:42 采纳率: 100%
浏览 109
已结题

代码出现非零返回如何解决

import math
def accont(a,b,c):
a=int(a)
b=int(b)
c=int(c)
P=int((a+b+c)/2)
S=int(math.sqrt(P*(P-a)(P-b)(P-c)))
return S
A=int(input())
B=int(input())
C=int(input())
LIS=[A,B,C]
LIS.sort()
if LIS[0]<LIS[1]+LIS[2] and LIS[0]-LIS[1]<LIS[2]:
RESULT=accont(A,B,C)
print("%.2f"%(RESULT))
else:
print("数据错误")
pass

  • 写回答

2条回答 默认 最新

  • 辉煌仪奇 2021-10-15 11:07
    关注

    你在这里出现了语法错误

    img


    修改意见,参照下方建议代码修改

    import math
    
    
    def accont(a, b, c):
        a = int(a)
        b = int(b)
        c = int(c)
        P = int((a + b + c) / 2)
        S = int(math.sqrt(P * (P - a)*(P - b)*(P - c)))
        return S
    
    
    A = int(input())
    B = int(input())
    C = int(input())
    LIS = [A, B, C]
    LIS.sort()
    if LIS[0] < LIS[1] + LIS[2] and LIS[0] - LIS[1] < LIS[2]:
        RESULT = accont(A, B, C)
        print("%.2f" % (RESULT))
    else:
        print("数据错误")
    

    有帮助请采纳,有问题继续交流,你的采纳是对我回答的最大的肯定和动力

    本回答被专家选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

问题事件

  • 系统已结题 11月4日
  • 专家已采纳回答 10月27日
  • 创建了问题 10月15日