2015-12-11 62 views
0

我正在开始使用Codechef。我在Python中提交了以下代码来解决this question运行时错误(NZEC) - Python/Codechef

下面的代码和codechef的在线(python)IDE以及我的本地IDE一起工作正常。但是,当我在codechef上提交它时,它会导致运行时错误(NZEC)。有人能向我解释这背后的原因吗?

withdrawCash = int(input()) 
totalCash = int(input()) 
if withdrawCash < totalCash and withdrawCash % 5 is 0: 
    totalCash = (totalCash - withdrawCash) - 0.5 
    print(totalCash) 
+0

[This](http://stackoverflow.com/questions/37022097/nzec-runtime-error-in-python)可能会帮助,因为我去过那里并摆脱它。 –

回答

0

该问题在一行中提供了两个输入。你的代码等待2行输入。将其更改为:

withdrawCash,totalCash = map(int,raw_input.split()) 
+0

它不工作。我得到同样的错误。 – Pavan

0

当您的代码在退出时不返回零时,会出现NZEC(非零退出代码)。这可能由于多种原因而发生,但是如果拆分输入不能解决问题,请为EOFerror添加例外。请只写:

try: 
    withdrawCash = int(input().split()) # raw_input in the case of Python 2 
except EOFerror: 
    print ("exit") # this is jst a pseudo statement ` 

正确使用缩进。我目前正在使用一个堆栈交换的Android应用程序,其中编写代码并不那么容易。当谈到Python时,codechef非常糟糕。切换到任何其他语言的CP。