추가 '가장 짧은 길이2'
This commit is contained in:
parent
3e1e3c9b23
commit
7c461bf3e8
|
|
@ -0,0 +1,24 @@
|
|||
import random
|
||||
s=[]
|
||||
x=0
|
||||
while x<10:
|
||||
n=random.randint(1,10)
|
||||
s.append(n)
|
||||
x=x+1
|
||||
s.sort()
|
||||
print(s)
|
||||
a=0
|
||||
b=[]
|
||||
c=[]
|
||||
d=0
|
||||
e=0
|
||||
min=s[-1]
|
||||
for a in range(len(s)-1):
|
||||
b.append([s[a+1]-s[a],s[a],s[a+1]])
|
||||
print(b)
|
||||
for d in range(len(b)):
|
||||
if min>b[d][0]:
|
||||
min=b[d][0]
|
||||
for e in range(len(b)):
|
||||
if s[e+1]-s[e]==min:
|
||||
print((s[e],s[e+1]))
|
||||
Loading…
Reference in New Issue