用asp.net中的C#写出一个数字排序的程序,要求是用Visual studio运行的,并且冒泡法除外
<!DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN""http://www.w3.org/TR/xhtml1/...
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>无标题页</title>
</head>
<body>
<form id="form1" runat="server">
<div>
</div>
</form>
</body>
</html>
怎么都没有这个的? 展开
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>无标题页</title>
</head>
<body>
<form id="form1" runat="server">
<div>
</div>
</form>
</body>
</html>
怎么都没有这个的? 展开
展开全部
可以用快速排序法!
38,40,46,56,79,84
你可以试一下这个算法,C#的:
private static void QuickSort(int[] R, int low, int high)
{
int pivotLoc = 0;
if (low < high)
{
pivotLoc = Partition(R, low, high);
QuickSort(R, low, pivotLoc - 1);
QuickSort(R, pivotLoc + 1, high);
foreach (object obj in R)
{
Console.Write(obj + " ");
}
Console.WriteLine("\n");
}
}
private static int Partition(int[] R, int low, int high)
{
int temp = R[low];
while (low < high)
{
if (low < high && temp <= R[high])
{
high--;
}
R[low] = R[high];
if (low < high && R[low] <= temp)
{
low++;
}
R[high] = R[low];
}
R[low] = temp;
return low;
}
R[]是要排序的数组,low,high就不用说了吧
38,40,46,56,79,84
你可以试一下这个算法,C#的:
private static void QuickSort(int[] R, int low, int high)
{
int pivotLoc = 0;
if (low < high)
{
pivotLoc = Partition(R, low, high);
QuickSort(R, low, pivotLoc - 1);
QuickSort(R, pivotLoc + 1, high);
foreach (object obj in R)
{
Console.Write(obj + " ");
}
Console.WriteLine("\n");
}
}
private static int Partition(int[] R, int low, int high)
{
int temp = R[low];
while (low < high)
{
if (low < high && temp <= R[high])
{
high--;
}
R[low] = R[high];
if (low < high && R[low] <= temp)
{
low++;
}
R[high] = R[low];
}
R[low] = temp;
return low;
}
R[]是要排序的数组,low,high就不用说了吧
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询