无聊中,写了一个给做你参考吧
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{
const int len = 5;
int[] a= new int[len];
int b;
string temp1="";
string temp2="";
try
{
System.Console.WriteLine("请输入{0}位数整数", len);
temp1 = System.Console.ReadLine();
for (int i = 0;
i < a.Length;
i++)
{
a = Convert.ToInt32(temp1.Substring(i, 1));
}
for (int i = 0;
i < a.Length;
i++)
{
for (int j = 0;
j < i;
j++)
{
if (a[j] < a)
{
b = a;
a = a[j];
a[j] = b;
}
}
}
for (int i = 0;
i < a.Length;
i++)
{
temp2 += a.ToString();
}
System.Console.WriteLine("原来的整数:" + temp1);
System.Console.WriteLine("调整后的整数:" + temp2);
}
catch (Exception e)
{
System.Console.WriteLine(e.Message);
}
finally
{
System.Console.ReadLine();
}
}
}
}