今天在朋友圈看到一道解不等式的题,很简单,真好电脑开着,就随便用python实现解题方案:
原题:有A,B,C,D四个数,满足 a+b>c+d , a+d>b+c , b+d>a+c 三个关系,从这些关系中,找出最小的那个数?
#!/usr/bin/python3
from random import randint
def mas():
while(1):
a=randint(1,100)
b=randint(1,100)
c=randint(1,100)
d=randint(1,100)
dicts=[('a',a),('b',b),('c',c),('d',d)]
if a+b>c+d and a+d>b+c and b+d>a+c:
t=min(a,b,c,d)
break
for s,value in dicts:
if value==t:
return 'minValue is: '+s
print (mas())