【发布时间】:2017-02-12 20:00:37
【问题描述】:
此代码用于最大成对乘积,我一直在对其进行测试,但遇到了一些问题。
import sys
import random
while True:
a=int(random.randrange(1,1000000,101))
keys =[] # keys is empety list
i=0
while i < a :
keys.append(int(random.randrange(1,10000,8)))
i=i+1
keys.sort()
print(keys[-1], keys[-2])
x=keys[-1]*keys[-2]
print( "the max is ",x)
但是,由于某种原因,代码的输出总是相同的。
9993 9993
the max is 99860049
9993 9993
the max is 99860049
9993 9993
the max is 99860049
9993 9993
the max is 99860049
我不明白为什么会发生这种情况,不胜感激。
【问题讨论】:
-
呃
keys也一样...
标签: python python-3.x code-testing