首页 > 试题广场 >

归并排序

[编程题]归并排序
  • 热度指数:2587 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 32M,其他语言64M
  • 算法知识视频讲解
请编程实现一个整型数组的归并排序。本题会人工判断,请严格按照题目描述完成

输入描述:
一个无序的整型数组,输入格式见输入样例


输出描述:
一个有序的整型数组,输出格式见输出样例
示例1

输入

[3, 1, 4, 5, 17, 2, 12]

输出

[1, 2, 3, 4, 5, 12, 17]
头像 _VanillaL
发表于 2022-08-30 16:05:26
#include <iostream> #include <string> #include <vector> #include <algorithm> using namespace std; int main(){     st 展开全文
头像 牛客96828638号
发表于 2022-07-13 16:45:23
def merge(left,right):     res=[]     i,j = 0,0     while i<len(lef 展开全文
头像 花儿无缺
发表于 2021-11-15 00:11:06
C的解法: #include <stdio.h> #include <stdlib.h> #include <string.h> typedef struct{     int num;     char k; &nb 展开全文
头像 牛客57073223号
发表于 2020-08-21 13:08:18
import java.util.Arrays; import java.util.Scanner; public class Main {     public static void main(String[] args){     展开全文
头像 牛客300075817号
发表于 2021-07-21 15:01:54
#include<iostream> #include<string> #include<sstream> #include<stdlib.h> using namespace std; int a[100005],n=0,i; void mergeS 展开全文