题解
2023-08-25 13:15:00
发布于:江苏
2阅读
0回复
0点赞
#include <iostream>
using namespace std;
int a[10005],b[10005];
void paixv(int a[],int b[],int n,int m){
int tmp[20005];
int i = 1,j = 1;
while (i <= n && j <= m){
if (a[i] <= b[j]){
cout << a[i] << " ";
i++;
}else{
cout << b[j] << " ";
j++;
}
}
while (i <= n){
cout << a[i] << " ";
i++;
}
while (j <= m){
cout << b[j] << " ";
j++;
}
return;
}
int main(){
int n,m;
cin >> n >> m;
for (int i = 1; i <= n;i++){
cin >> a[i];
}
for (int i = 1; i <= m;i++){
cin >> b[i];
}
paixv(a,b,n,m);
return 0;
}
这里空空如也
有帮助,赞一个