我是靠谱客的博主 能干月亮,这篇文章主要介绍分治法求数组最大整数,现在分享给大家,希望可以做个参考。

#include <iostream>
using namespace std;
int find(int a[],int low,int high){
if(low==high){
return a[low];
}else{
int mid=(high+low)/2;
int left=find(a,low,mid);
int right=find(a,mid+1,high);
return left>right?left:right;
}
}
int main()
{//时间复杂度O(n)
int a[9]={1,2,3,114,15,6,7,8,9};
cout<<find(a,0,8);
return 0;
}

 

最后

以上就是能干月亮最近收集整理的关于分治法求数组最大整数的全部内容,更多相关分治法求数组最大整数内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(138)

评论列表共有 0 条评论

立即
投稿
返回
顶部