Crossin的编程教室

标题: 从1~n中,随机取m个数。1<=m<=n [打印本页]

作者: chenaaa    时间: 2016-9-3 14:09
标题: 从1~n中,随机取m个数。1<=m<=n
#coding=utf-8
from random import randint
print 'input n:\n'
n=input() print 'input m:\n'
m=input()
if m>=1 and n>=m:   
    print [randint(1,int(n+1)) for i in range(int(m))]
else:   
    print '输入不正确'




欢迎光临 Crossin的编程教室 (https://bbs.crossincode.com/) Powered by Discuz! X2.5