ss
2024-05-14 22:08:25
发布于:广东
2阅读
0回复
0点赞
#include<bits/stdc++.h>
using namespace std;
int cmp(int a,int b){
return a<b;
}
int main(){
int n,m;
cin >> n >> m;
int a[10005],b[10005];
for(int i=0;i<n;i++) cin >> a[i];
for(int i=0;i<m;i++) cin >> b[i];
int i=0,j=0;
a[n] = 1e9;
b[m] = 1e9;
while(i<n||j<m){
if(a[i] < b[j]){
cout << a[i] << " ";
i++;
}else if(b[j] < a[i]){
cout << b[j] << " ";
j++;
}else{
cout << a[i] << " " << b[j] << " ";
i++; j++;
}
}
return 0;
}
这里空空如也
有帮助,赞一个