冒泡排序
2013-12-17 10:26
323 查看
一觉醒来,没事干,写个冒泡醒醒睡意!
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int[] arrs = { 1, 3, 5, 4, 2, 3, 5, 3, 5, 6, 8, 9, 2, 10 };
Srot(arrs);
foreach (int item in arrs)
{
Console.WriteLine(item);
}
Console.ReadKey();
}
public static Array Srot(int[] arr)
{
int temp;
for (int i = 0; i < arr.Length - 1; i++)
{
for (int j = 0; j < arr.Length - 1 - i; j++)
{
if (arr[j] > arr[j + 1])
{
temp = arr[j];
arr[j] = arr[j + 1];
arr[j + 1] = temp;
}
}
}
return arr;
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int[] arrs = { 1, 3, 5, 4, 2, 3, 5, 3, 5, 6, 8, 9, 2, 10 };
Srot(arrs);
foreach (int item in arrs)
{
Console.WriteLine(item);
}
Console.ReadKey();
}
public static Array Srot(int[] arr)
{
int temp;
for (int i = 0; i < arr.Length - 1; i++)
{
for (int j = 0; j < arr.Length - 1 - i; j++)
{
if (arr[j] > arr[j + 1])
{
temp = arr[j];
arr[j] = arr[j + 1];
arr[j + 1] = temp;
}
}
}
return arr;
}
}
}
相关文章推荐
- 10.9.1完整版版更新了。
- 6410之LCD驱动程序(层次分析)
- mysqldump导出--数据+结构+(函数+存储过程)
- Gruntjs提高生产力(三)
- DataGridView中的列类型设置为Combo,模式为可以选择&可以输入,解决方法。
- github push代码 403
- Window 能访问某些网站,不能访问一些网的解决方法
- Android生成倒影效果
- java并发编程(读书笔记总结)
- static用法小结
- Oracle Timezone
- Oracle Database Compression 1 - Basic Compression
- sql server 对象名无效的解决方法
- win7下声音图标消失的解决办法
- WPF:面板
- Oracle Scalar Subquery Cache
- hbase中关于scan的操作
- Tomcat启动行参数
- Web开发人员应当充分使用的10大jQuery插件
- 8天学通MongoDB——第四天 索引操作