C#快速排序算法
来源:互联网 发布:黑莓转制软件原理 编辑:程序博客网 时间:2024/05/29 04:46
唉 算法功底太差了~~
using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace ConsoleApplication1{ class Class1 { public static void Main(string[] avg) { int[] source = new int[100]; Random r = new Random(); for (int i = 0; i < source.Length; i++) { source[i] = r.Next(1000); Console.WriteLine(source[i]); } sort(source, 0, source.Length - 1); Console.WriteLine(); foreach (var temp in source) { Console.WriteLine(temp); } Console.ReadLine(); } public static void sort(int[] source, int startPoint, int endPoint) { if (startPoint < endPoint) { int i=partrn(source, startPoint, endPoint); sort(source, startPoint, i - 1); sort(source, i + 1, endPoint); } } public static void swap(int[] source, int left, int right) { source[left] = source[right] + source[left]; source[right] = source[left] - source[right]; source[left] = source[left] - source[right]; } public static int partrn(int[] source, int left, int right) { int pivot = source[left]; while (left < right) { while (left < right && source[right] >= pivot) right--; if (left < right) { swap(source, left, right); } while (left < right && source[left] <= pivot) left++; if (left < right) { swap(source, left, right); } } source[left] = pivot; return left; } }}
- C#算法 快速排序
- 快速排序算法c#
- C#快速排序算法
- C#快速排序算法
- 【算法】C#快速排序类
- 【算法】C#快速排序类
- C#实现快速排序算法
- C#快速排序算法实现
- 快速排序算法c#版
- C#算法-------(五)快速排序
- 快速排序算法-c#版
- c# 快速排序算法实现
- C#实现快速排序算法
- 【快速排序算法-C#实现】
- 【算法】C#快速排序类(转载)
- C#泛型快速排序算法
- 快速排序算法(C#实现)
- c#冒泡排序算法和快速排序算法
- OpenGL中gl,glu,glut的区别
- 设计模式C++实现(3)——适配器模式
- c++ Socket编程流程
- Silverlight实战示例4(兼集合属性的妙用)--业务逻辑与服务层
- truncate与delete的区别
- C#快速排序算法
- 二进制在数学中的妙用
- 设计模式C++实现(4)——单例模式
- Framework StatusBar添加(wifi,bluetooth,gps,sound,rotate)控制面板
- 用户CPU时间 系统CPU时间 时钟时间
- 设计模式C++实现(5)——原型模式、模板方法模式
- html
- 设计模式C++实现(6)——建造者模式
- 不能抱怨