- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace 冒泡排序
- {
- class Program
- {
- static voidMain(string[] args)
- {
- string[] ss =new string[5] {"aaa","a","aa","aaaaa","aaaa" };
- for(inti =0; i < ss.Length-1; i++)
- {
- for(intj = i+1; j < ss.Length; j++)
- {
- if(ss[i].Length > ss[j].Length)
- {
- stringa = ss[i];
- ss[i] = ss[j];
- ss[j] = a;
- }
- }
- }
- for(inti =0; i < ss.Length; i++)
- {
- Console.WriteLine(ss[i]);
- }
- Console.ReadLine();
- for(inti =0; i < ss.Length -1; i++)
- {
- for(intj = i +1; j < ss.Length; j++)
- {
- if(ss[i].Length <ss[j].Length)
- {
- stringa = ss[i];
- ss[i] = ss[j];
- ss[j] = a;
- }
- }
- }
- for(inti =0; i < ss.Length; i++)
- {
- Console.WriteLine(ss[i]);
- }
- Console.ReadLine();
- }
- }
- }
来源: http://www.bubuko.com/infodetail-1965385.html