资源简介
关于算法中的螺钉螺母问题。思路不难,利用快速排序,关键是在一些细节上的注意
代码片段和文件信息
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace 螺钉螺母
{
class Program
{
static void Main(string[] args)
{
make boltAnd = new make();
boltAnd.output(boltAnd.AboltAnd.a);
boltAnd.BoltAndNut(boltAnd.AboltAnd.a09);
boltAnd.output(boltAnd.AboltAnd.a);
Console.ReadKey();
}
}
class make
{
public int[] A = new int[10] { 3 0 2 4 6 8 1 5 7 9 };
public int[] a = new int[10] { 1357902468};
public void BoltAndNut(int[] A int[] a int begin int end)
{
Console.WriteLine();
Console.WriteLine(“你好“);
if (begin {
int index= this.pisition(Aabeginend);
output(A a);
BoltAndNut(A a begin index - 1);
BoltAndNut(A a index + 1 end);
//output(A a);
}
}
public int pisition(int []Aint []aint beginint end)
{
int i = begin j = end;
int index = 0;
do
{
while (a[i] <= A[begin] && i <= end)
{
if (a[i] == A[begin])
{
swap(a begin i);
}
i++;
}
while (a[j] >= A[begin] && j >=begin)
{
if
评论
共有 条评论