No one answers?
Given N numbers, your job is to sort them from smallest to largest ^_^
Enter an integer in the first line of
, n(1< =n< =200000), which means there are N numbers followed by N lines, one number per line
Output
output N lines, Says it has sort of sample input number N < br / > < br / > 5 < br / > 2 < br / > 3 < br / > 1 < br / > 4 < br / > < br / > 5 sample output < br / > 1 < br / > 2 < br / > < br / > 4 < br / > < br / > 5 OJ: segment error, check whether there is an array, Pointer exception, access to memory area that should not be accessed
Code:
#include <bits/stdc++.h>
using namespace std;
int n,t;
int minn=1e9,maxn=-1e9;
int a[200005];
int main(){
cin>>n;
for(int i=1; i<=n; i++){
cin>>t;
a[t]++;
minn=min(minn,t);
maxn=max(maxn,t);
}
for(int i=minn; i<=maxn; i++){
for(int j=1; j<=a[i]; j++){
cout<<i<<" ";
}
}
return 0;
}
0 Answer
这家伙很懒,什么都没留下...