首页 > 编程语言 > 详细

使用C#完成冒泡排序

时间:2018-11-03 12:16:40      阅读:102      评论:0      收藏:0      [点我收藏+]

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace 冒泡排序
{
class Program
{
static void Main(string[] args)
{
int[] sores = { 18, 19, 20, 45, 62, 32, 89, 75, 41, 32, 69 };

for (int i = 0; i < sores.Length-1; i++)
for (int j = 0; j<sores.Length-1; j++)
{
int team;
if (sores[j] < sores[j+1])
{
team = sores[j];
sores[j] = sores[j +1];
sores[j +1] = team;


}
}
Console.WriteLine("按顺序从小到大排列后的数组是");
for(int i=0;i<sores.Length;i++)
Console.Write(sores[i]+" ");
Console.ReadKey();
}
}
}

技术分享图片

 

使用C#完成冒泡排序

原文:https://www.cnblogs.com/qmk-716/p/9900118.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!