# | Problem | Pass Rate (passed user / total user) |
---|---|---|
14223 | Lab2_Merge Sort Problem |
|
Description
Given an integer array a1,a2,⋯ ,an with n integers, sort the array in non-ascending order using merge sort. Output the sorted array.
Input
The first line is an integer n, being the size of the integer array.The second line contains nn integers a1,a2,⋯ ,an, being the elements of the integer array.
Constraints
Output
Output the sorted array in one line.
Please append a space after each number, and add a newline at the end of the output.
void merge(); //merge two sorted array void merge_sort(); //divide and conquer int main() { /* int n; cin >> n; ... Read the input file */ /* Using merge_sort method to sort your array */ /* Output the sorted array for(int i = 0; i < arr.size(); i++) { cout << arr[i] << ' '; } cout << endl; */ }