#define SIZE 100 int m[SIZE], t[SIZE] ; void CopyBackToBack(int low, int high, int mid) { int i ; for(i = mid ; i >= low ; t[i] = m[i--]); for(i = mid + 1 ; i <= high ; t[high + mid + 1 - i] = m[i++]); } void Merge(int low, int high) { int i, j, k ; i = low ; j = high ; for(k = low ; k <= high ; k++) if(t[i] < t[j]) m[k] = t[i++]; else m[k] = t[j--]; } void mergesort(int low, int high) { int mid, i, j, k ; if(high > low) { mid = (high + low)/2; mergesort(low, mid); mergesort(mid + 1, high); CopyBackToBack(low, high, mid) ; Merge(low, high) ; } } int main() { int n, i; printf("Enter the number of data :") ; scanf("%d",&n); printf("\nEnter the data\n") ; for(i = 0 ; i < n ; scanf("%d", &m[i++])); mergesort(0,n-1); printf("The sorted data are\n") ; for(i = 0 ; i < n ; printf("%d ", m[i++])); printf("\n") ; }