using System.Linq;classKata{publicstaticintMaxNumber(int n){returnint.Parse(string.Concat(n.ToString().OrderByDescending(x =>char.GetNumericValue(x))));}}
答案3:
using System;using System.Text.RegularExpressions;classKata{publicstaticintMaxNumber(int n){int[]l =newint[(""+n).Length];int i =-1;do{l[++i]= n%10;n /=10;}while(n>0);
Array.Sort(l); Array.Reverse(l);
Console.WriteLine(string.Join("", l));return Int32.Parse(string.Join("",l));}//it's an alien with 3 eyes, 3 eyes !!}
答案4:
using System;classKata{publicstaticintMaxNumber(int n){char[] arr=n.ToString().ToCharArray();
Array.Sort(arr);
Array.Reverse(arr);returnint.Parse(newstring(arr));}}
答案5:
using System.Linq;classKata{publicstaticintMaxNumber(int n){returnint.Parse(string.Join("",n.ToString().ToCharArray().OrderByDescending(x => x).Select(x => x.ToString()).ToArray()));}}
答案6:
using System.Linq;classKata{publicstaticintMaxNumber(int n){returnint.Parse(string.Concat(n.ToString().ToArray().OrderByDescending(a => a)));}}
答案7:
using System.Linq;classKata{publicstaticintMaxNumber(int n){returnint.Parse(string.Concat(n.ToString().ToCharArray().OrderByDescending(x => x).ToArray()));}}
答案8:
using System.Linq;classKata{publicstaticintMaxNumber(int n){returnint.Parse(string.Join(string.Empty, n.ToString().OrderByDescending(c => c)));}}
答案9:
using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;classKata{publicstaticintMaxNumber(int n){return Int32.Parse(string.Join("",Array.ConvertAll(n.ToString().ToArray(), x => Int32.Parse(x.ToString())).ToList().OrderByDescending(x => x)));}}