gpt4 book ai didi

c++ - 在C++中合并排序

转载 作者:行者123 更新时间:2023-12-01 15:07:53 25 4
gpt4 key购买 nike

在竞争性编码中,我对编码合并排序有疑问
我知道如何用三个参数合并排序即

merge_sort(int arr[],int left,int right)
{
\\rest of code
}

但是问题是
merge_sort(int arr[],int size)
{
\\rest of code
}

如何对2个参数执行合并排序?

最佳答案

您可以这样做:

merge_sort(int arr[],int size)
{
merge_sort(arr, 0,size-1) // merge_sort(int arr[],int left,int right)
}

现在,您从2自变量1调用3自变量函数。

关于c++ - 在C++中合并排序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62051475/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com