Cod sursa(job #330799)
| Utilizator | Data | 11 iulie 2009 16:10:05 | |
|---|---|---|---|
| Problema | Sortare prin comparare | Scor | 0 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.61 kb |
#include<iostream>
#define MAX_V 2000000+1
using namespace std;
void sort(int a[],int n)
{
int i,c[MAX_V];
int *b = new int[500000];
for(i = 0; i < MAX_V; i++) c[i] = 0;
for(i = 0; i < n; i++)
c[a[i]]++;
for(i = 1; i < MAX_V; i++)
c[i] += c[i-1];
for(i = n-1; i >= 0; i--)
{
printf("%d ",a[i]);
c[a[i]]--;
}
}
int main()
{
freopen("algsort.in","r",stdin);
freopen("algsort.out","w",stdout);
int n ;
int * a = new int[500000];
scanf("%d",&n);
sort(a,n);
return 0;
}
