From b25e6baeb1b12b2e12ae1d3b9ba15f17e820339f Mon Sep 17 00:00:00 2001 From: wei <1219738919@qq.com> Date: Thu, 6 Aug 2020 17:32:55 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BD=92=E5=B9=B6=E6=8E=92=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- MergeSort.java | 51 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 MergeSort.java diff --git a/MergeSort.java b/MergeSort.java new file mode 100644 index 0000000..f0850b3 --- /dev/null +++ b/MergeSort.java @@ -0,0 +1,51 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package sort; + +/** + * + * @author User + */ +public class MergeSort { + + private static int[] aux; + public static void merge(int[] a,int low, int mid,int high){ + int i=low; + int j=mid+1; + + for(int k=low;k<=high;k++){ + aux[k]=a[k]; + } + for(int k=low;k<=high;k++){ + if(i>mid){ + a[k]=aux[j++]; + + } + else if(j>high){ + a[k]=aux[i++]; + } + else if(aux[j]