作业帮 > 综合 > 作业

合并排序错误 static int n = 10;static float A[] = new float[n];sta

来源:学生作业帮 编辑:大师作文网作业帮 分类:综合作业 时间:2024/11/12 07:21:46
合并排序错误
static int n = 10;
static float A[] = new float[n];
static float B[] = new float[n];
public static void mergeSort(float A[],int left,int right )
{
if(left < right)
{
int mid = (left + right) / 2;
mergeSort(A,left,mid);
mergeSort(A,mid + 1,right);
merge(A,B,left,mid,right);
copy(A,B,left,right);
}
}
private static void merge(float A[],float B[],int left,int mid,int right)
{
int i = left,j = mid + 1,k = left;
while(i
合并排序错误 static int n = 10;static float A[] = new float[n];sta
static int n = 10;
static float A[] = new float[n];
static float B[] = new float[n];
public static void mergeSort(float A[],int left,int right )
{
if(left < right)
{
int mid = (left + right) / 2;
mergeSort(A,left,mid);
mergeSort(A,mid + 1,right);
merge(A,B,left,mid,right);
copy(A,B,left,right);
}
}
private static void merge(float A[],float B[],int left,int mid,int right)
{
int i = left,j = mid + 1,k = left;
while(i