Zoe

定义一个字符串数组,按字符串长度从大到小打印出来

namespace _2017_2_28___比较字符串数组
{
    class Program
    {
        static void Main(string[] args)
        {
            String[] a = new string[6] { "qwer", "erfdc", "rtg", "asdfgh", "we" ,"dhsgdjdsj"};
            String b;
            
            for (int i = 0; i < 6;i++ )
            {
                for (int j = i + 1; j < 6;j++ ) 
                {
                    if(a[i].Length<a[j].Length)
                    {
                        b = a[i];
                        a[i]=a[j];
                        a[j] = b;
                      
                    }
                   
                }
                Console.WriteLine(a[i]);
            }
            Console.ReadLine();
        }
    }
}

 

posted on 2017-03-01 16:12  口袋里的SKY  阅读(117)  评论(0编辑  收藏  举报