classProgram {Static voidMain (string[] args) {List<int> c =Newlist<int> () {1,2,3,4,5 }; C.sort (); varresult = GetNumber (c,27423536); Console.WriteLine ("{0}", result); Console.readkey (); } Private Static intGetNumber (list<int> C,intk) {c.sort (); intresult =0; intKK =K; List<int> eachnum =Newlist<int>(); //convert each bit of the K to a list. while(k! =0) {Eachnum.add (k%Ten); K= k/Ten; } //get the each bit which is larger or equal the same position of K. for(inti = Eachnum.count-1; I >=0; i--) {result= result *Ten+Getcurrentnum (c, eachnum[i]); } //If The result by below is small than target. Replace the number from low position. intj =0; while(Result <= KK && J <eachnum.count) {J++; if(C.where (item = Item > EACHNUM[J-1]). Count () = =0) { Continue; } result= (Result/(int) Math.pow (Ten, j)) * (int) Math.pow (Ten, J); Result= result + getminvallargerthant (c.where item = item > EACHNUM[J-1]). First (), C.first (), J-1); } //If The result is a still small than target, carry in adding. if(Result <=KK) {Result= Getminvallargerthant (C.where (item = Item >0). First (), C.first (), eachnum.count); } returnresult; } Public Static intGetminvallargerthant (intFirstisnotzero,intFirstnum,intlength) { intresult =Firstisnotzero; for(inti =0; i < length; i++) {result= result *Ten+Firstnum; } returnresult; } //Get for each number min value larger than the same position. Public Static intGetcurrentnum (list<int> C,inthighnum) { foreach(intCIteminchc) {if(CItem >=highnum) { returnCItem; } } return 0; } }View Code
C # implementation: Given a [0-9] array, the minimum value of any number consisting of an array is evaluated