Random production does not repeat numbers

xiaoxiao2021-03-05  24

Random Random = New Random (DataTime.now.milliseCond);

-------------------------------------------------- ------------

// Generate 20 non-repetitive random numbers! ! ! Int [] rands = new int [10]; int value, count, k; value = 0; count = 0; k = 0; bool ys = true; for (int i = 0; i

-------------------------------------------------- ------------------------------

Static void main (string [] args) {arraylist mylist = new arraylist (); arraylist list = new arraylist (); random ran = new random (); for (int i = 0; i <100; i ) mylist.add (i.tostring ()); for (int i = 100; I> 0; i -) {int a = 0; a = ran.next (i); list.add (mylist [a] .tostring () ); Mylist.removeat (a);} for (int i = 0; i <100; i ) {console.writeline (list [i] .tostring ());}}

转载请注明原文地址:https://www.9cbs.com/read-37786.html

New Post(0)