简单的排序

数据范围不大,但是数字很多,用桶排序,不会的可以看这个:https://www.cnblogs.com/wzl19981116/p/9740426.html

#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include <iomanip>
#include<cmath>
#include<float.h> 
#include<string.h>
#include<algorithm>
#define sf scanf
#define scf(x) scanf("%d",&x)
#define pf printf
#define prf(x) printf("%d\n",x)
#define mm(x,b) memset((x),(b),sizeof(x))
#include<vector>
#include<queue>
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=a;i>=n;i--)
typedef long long ll;
const ll mod=1e9+100;
const double eps=1e-8;
using namespace std;
const double pi=acos(-1.0);
const int inf=0xfffffff;
const int N=1e5;
int a[N*2+7];
int main()
{
	int n,x;
	scf(n);
	mm(a,0);
	while(n--)
	{
		scf(x);
		a[x+N]++;
	}
	int temp=1; 
	rep(i,0,2*N+1)
	{
		rep(j,0,a[i])
		{
			if(temp)
			{
				pf("%d",i-N);
				temp=0;
			}
			
			else
			pf(" %d",i-N);
		}
	}
	return 0;
}
posted @ 2018-12-08 12:23  一无所知小白龙  阅读(143)  评论(0编辑  收藏  举报