永发信息网

50个数字每次系统会从里面选出一个随机数字我该如何选出5个数字可以完全躲过系统每次随机出的一个数

答案:2  悬赏:60  手机版
解决时间 2021-12-17 18:29
  • 提问者网友:记忆里的那片海
  • 2021-12-17 01:10
50个数字每次系统会从里面选出一个随机数字我该如何选出5个数字可以完全躲过系统每次随机出的一个数
最佳答案
  • 五星知识达人网友:想做你的礼物
  • 2021-12-17 01:30
dim a,b,c,d,e as integer a=Int((50 - 1 + 1) * Rnd + 1) do while b=a b=Int((50 - 1 + 1) * Rnd + 1) loop do while c=a or c=b c=Int((50 - 1 + 1) * Rnd + 1) loop do while d=a or d=b or d=c d=Int((50 - 1 + 1) * Rnd + 1) loop do while e=a or e=b or e=c or e=d e=Int((50 - 1 + 1) * Rnd + 1) loop 从1-9中选两个不重复的数字 dim a,b as integer a=Int((50 - 1 + 1) * Rnd + 1) do while b=a b=Int((50 -沪禒高溉薨防胳狮供饯 1 + 1) * Rnd + 1) loop
全部回答
  • 1楼网友:不正经的草莓
  • 2021-12-17 02:08

list<int> lint = new list<int>();

random rnd = new random();

// 放入 1-50 个数到集合 for (int i = 0; i < 50; i++) {     lint.add(i+1); }

// 如果集合中元素大于 0 while (lint.count()>0) {     int index = rnd.next(lint.count());// 根据集合元素个数随机创建一个索引     console.writeline(lint[index]);// 用上面个这索引得到元素中的数     lint.removeat(index);// 移除指定索引处的元素。 }

我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯