Pagini recente » Cod sursa (job #2395030) | Cod sursa (job #71833) | Cod sursa (job #916091) | Cod sursa (job #3123190) | Cod sursa (job #2136297)
#include <cstdio>
#include <queue>
int N, x;
std :: queue<int> bucket1[65536], bucket2[65536];
int main()
{
freopen("algsort.in", "r", stdin);
freopen("algsort.out", "w", stdout);
scanf("%d", &N);
for(int i = 0; i < N; ++i)
{
scanf("%d", &x);
bucket1[x & 65535].push(x);
}
for(int i = 0; i != 65536; ++i)
{
while(!bucket1[i].empty())
{
x = bucket1[i].front(); bucket1[i].pop();
bucket2[x >> 16 & 65535].push(x);
}
}
for(int i = 0; i != 65536; ++i)
{
while(!bucket2[i].empty())
{
printf("%d ", bucket2[i].front()); bucket2[i].pop();
}
}
return 0;
}