python运行时错误(NZEC)

2024-04-26 22:02:15 发布

您现在位置:Python中文网/ 问答频道 /正文

initial_bal = int( input("enter initial balance"))
withdraw_money = int( input("enter balance to withdraw"))
f = 0
if withdraw_money % 5 == 0 :
    if ( withdraw_money + 0.5 ) <= initial_bal:
        f = 1

if f == 1:
    account_bal = initial_bal - ( withdraw_money + 0.5 )
    print ("remaining balance : " , account_bal)
else :
    print(initial_bal)

当我把上面写的代码提交给codechef时,它抛出了运行时错误(NZEC)。在我的机器上工作正常。 谁能告诉我,我的代码错误在哪里?在


Tags: to代码inputif错误accountinitialint
1条回答
网友
1楼 · 发布于 2024-04-26 22:02:15

首先,你不必打印“输入初始余额”之类的东西。你只需要打印测试用例中给出的内容。只需打印测试用例中给出的内容即可。。没别的。。。
这是python中的实际代码

class Main:

    s=raw_input()
    s=s.split(" ")
    x=float(s[0])
    y=float(s[1])
    if(x%5==0 and x+0.50<=y):
        p=y-x-0.50
        print("%.2f"%p)
    else:
        print("%.2f"%y) 

相关问题 更多 >