C#字符串排序

一、字符串排序
namespace 字符串排序
{
    class Program
    {
        static void Main(string[] args)
        {
            string num;
            num = Console.ReadLine();
            char[] array = num.ToCharArray();
            
           
            for (int i = 0; i < array.Length;i++ )
            {
                Console.Write(array[i]);
            }
            Console.WriteLine();
            Console.WriteLine("排序后:");
            char temp;
           
            
            for (int i = 0; i < array.Length - 1; i++)
                for (int j = 0; j < array.Length - i - 1;j++ )
                {
                 //   int a=string.Compare(array[j],array[j+1],true);
                    if(array[j]>array[j+1])
                    {
                        temp=array[j];
                        array[j]=array[j+15];
                        array[j+1]=temp;
                        
                        
                    }
                }
            for (int i = 0; i < array.Length;i++ )
            {
                Console.Write(array[i]);
            }

            Console.ReadLine();
        }
    }
}

你可能感兴趣的:(C#)