畅连信息科技吧 关注:1贴子:6
  • 0回复贴,共1

数组字符串的冒泡排序从小到大

只看楼主收藏回复

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication8
{
class Program
{
static void Main(string[] args)
{
string[] qiu = {"科比布莱恩特","邓肯","布加迪","劫" };
for (int i = 0; i < qiu.Length-1; i++)
{
for (int j = 0; j < qiu.Length-1; j++)
{
if (qiu[j].Length>qiu[j+1].Length)
{
string temp = qiu[j];
qiu[j] = qiu[j + 1];
qiu[j+1] = temp;
}
}
}
for (int i = 0; i < qiu.Length; i++)
{
Console.WriteLine(qiu[i]);
Console.ReadKey();
}
}
}
}


IP属地:山东1楼2016-05-21 09:16回复