题解
2024-02-24 12:13:22
发布于:云南
5阅读
0回复
0点赞
#include<bits/stdc++.h>
using namespace std;
int a[105],b[105];
int main(){
int n; cin >> n;
int midx = 1,widx = 1;
for(int i = 1;i <= n;i++){
int t; cin >> t;
if(t > 0){
a[midx] = t;
midx++;
}else{
b[widx] = t;
widx++;
}
}
sort(a + 1,a + midx + 1);
sort(b + 1,b + widx + 1);
for(int i = 2;i <= midx;i++){
cout << a[i] << " ";
}
for(int i = 1;i < widx;i++){
cout << b[i] << " ";
}
return 0;
}
这里空空如也
有帮助,赞一个