你好我试图用Python语言编写一个程序,要求用户输入一组1的数量和0的和我想要的程序来告诉我,如果我有和偶数零或奇数个零或根本不为零。谢谢你的帮助!!确定的研究,如果输入的是偶数或奇数
forstate = "start"
curstate = "start"
trans = "none"
value = 0
print "Former state....:", forstate
print "Transition....:", trans
print "Current state....", curstate
while curstate != "You hav and even number of zeros":
trans = raw_input("Input a 1 or a 0: ")
if trans == "0" and value <2:
value = value + 1
forstate = curstate
elif trans == "1" and value < 2:
value = value + 0
forstate = curstate
curstate = str(value) + " zeros"
if value >= 2:
curstate = "You have and even number of zeros"
print "former state ...:", forstate
print "Transition .....:", trans
print "Current state....", curstate
你有什么这么远吗? – 2011-02-09 02:17:38
到目前为止你有什么? – OscarRyz 2011-02-09 02:17:49