标签:creat size write ace argv port std str array
import sys
import random
import stdarray
import stdio
m = int(sys.argv[1])
n = int(sys.argv[2])
# Initialize array perm = [0,1,...,n-1]
perm = stdarray.create1D(n, 0)
for i in range(n):
perm[i] = i
# Create a random sample of size m in perm[0,..m)
for i in range(m):
r = random.randrange(i, n)
# Exchange perm[i] and perm[r].
temp = perm[r]
perm[r] = perm[i]
perm[i] = temp
# Write the results.
for i in range(m):
stdio.write(str(perm[i]) + ‘ ‘)
stdio.writeln()
无放回抽样(Sampling without replacement)
标签:creat size write ace argv port std str array
原文地址:http://www.cnblogs.com/cdf4745/p/7263148.html