我决定,我想自动化数学谜题的解决,但是,它并没有在Python工作虽然,我已经成功地做到了在批处理:While循环不工作(蟒蛇)
@echo off
set people=1
set handshakes=0
set cnt=0
:LOOP
set /A people+=1
set /A cnt+=1
set /A handshakes+=%cnt%
echo.handshakes:%handshakes%,people=%people%
if "%handshakes%" NEQ "66" Goto :LOOP
echo.---------Final Result------------
echo.Handshakes:%handshakes%
echo.People:%people%
pause > nul
exit /b
但是,对于一个非常奇怪的原因,下面的Python代码不起作用:
people = 1
handshakes = 0
cnt = 0
while a < 66:
people+=1
cnt+=1
handshakes+=cnt
print (handshakes)
print (people)
raw_input()
谜: 在一次聚会,大家握手其他人。有66次握手。派对上有多少人?
当你问一个问题时,千万不要说“不行”。总是解释程序如何失败。提供确切的错误消息。 – 2013-03-15 18:54:02
没有工作,有点不确定。你得到42,有错误还是会爆炸? – jeb 2013-03-15 18:54:29