标题: 问题求解 [打印本页] 作者: 1861674 时间: 2019-8-29 15:30 标题: 问题求解 # -*- coding: utf-8 -*-
import random
'''
a1=raw_input()
a=a1.replace(' ',"")
c={}
for i in a:
if i in c:
c[i] =c[i]+1
else:
c[i]=1
c=sorted(c.items(),key=lambda c: c[1],reverse=True)
for i in c:
print i
'''
ss=100
x=True
while x==True:
def xxxx():
count=0
for i in range(3):
a=random.choice([1,6])
count +=a
print a
return count
def xxxx1(b,c,ss,count):
print b,c,ss,count
if b==0:
if count <11:
ss=ss+2*c
print ss
else :
ss=ss-c
print ss
if b==1:
if count >10:
ss=ss+2*c
print ss
else:
ss=ss-c
print ss
if b==count:
ss=ss+10*c
print ss
else :
ss=ss-c
print ss
return ss
count=xxxx()
b=input('请输入猜的数字')
if b<2 or b>18:
print '数字过大或过小'
else :
c=input('请输入下的积分')
if c<1 or c>ss:
print '积分不足'
else :
ss=xxxx1(b,c,ss,count)
if ss>150:
x=False
为什么输出的数字过大或过小会了乱码,积分不足不会乱码