题解
2023-08-25 13:14:09
发布于:江苏
34阅读
0回复
0点赞
#include <cmath>
#include <iostream>
using namespace std;
int a[105];
void huafen(int l,int r){
if (l == r) return;
int mid = ceil((l + r) / 2);
int tmp[105] = {0},tmp2 = {0};
cout << "[";
for (int i = l; i <= mid;i++){
cout << a[i] << " ";
}
cout << "],[";
for (int i = mid + 1; i <= r;i++){
tmp2 = a[i];
cout << a[i] << " ";
}
cout << "]" << endl;
huafen(l,mid);
huafen(mid + 1,r);
}
int main(){
int n;
cin >> n;
for (int i = 1; i <= n; i++){
cin >> a[i];
}
huafen(1,n);
return 0;
}
全部评论 2
6
2023-09-02 来自 江苏
0666
2023-08-25 来自 江苏
0
有帮助,赞一个