Using System; Using System. Collections. Generic; Using System. LINQ; Using System. text; Namespace Www.cnblogs.com. rock_chen { Class Program { /// <Summary> /// It is known that random. Next (100) generates 1 to random data that is not repeated. /// </Summary> /// <Param name = "ARGs"> </param> Static Void Main ( String [] ARGs) {generaterandom = New Generaterandom (); VaR Result = Generaterandom. Calc (); console. writeline ( String . Join ( " , " , Result); console. writeline (); console. writeline ( String . Join ( " , " , Result. orderby (P => P). toarray (); console. Read ();}} Public Class Generaterandom {random =New Random (); Public Int [] Calc (){ Int [] Ary = New Int [ 100 ]; Int Count = 0 ; Int Currentindex = 0 ; Int K = 0 ; While (Count < 100 ){ VaR Index = Randomint (); If (Ary [currentindex] = 0 ) {Ary [currentindex] = Index; Ary [Index -1 ] = Currentindex + 1 ; Currentindex = Index- 1 ; Count = 2 ; Continue ;} If (Ary [index- 1 ] = 0 & Currentindex! = Index- 1 ) {Ary [Index - 1 ] = Ary [currentindex]; Ary [currentindex] = Index; currentindex = Index- 1 ; Count ++ ;} Else { While (K < 100 & Ary [k]>0 ) {K ++ ;} If (Currentindex! = K & K < 100 ) {Ary [k] = Ary [currentindex]; Ary [currentindex] = K + 1 ; Currentindex = K; count ++;}}} Return Ary ;} Public Int Randomint (){ Return (Random. Next ( 1 , 10 )- 1 )* 10 // 10-80 dozens + Random. Next ( 1 , 10 ) + Random. Next ( 1 , 10 )- 1 // Limit 17 + (Random. Next ( 1 , 10 )& 3 ); // 0-3 }}}