Cod sursa(job #240035)
Utilizator | Data | 6 ianuarie 2009 18:42:11 | |
---|---|---|---|
Problema | Sortare prin comparare | Scor | Ascuns |
Compilator | cpp | Status | done |
Runda | Marime | 0.41 kb |
#include <stdio.h>
#define maxn 500010
int n;
int a[maxn];
int main()
{
freopen("algsort.in", "r", stdin);
freopen("algsort.out", "w", stdout);
int i, j, aux;
scanf("%d ", &n);
for (i = 1; i <= n; i++) scanf("%d ", &a[i]);
for (i = 1; i <= n; i++)
for (j = i+1; j <= n; j++)
if (a[j] < a[i]) aux = a[i], a[i] = a[j], a[j] = aux;
for (i = 1; i <= n; i++) printf("%d ", a[i]);
printf("\n");
return 0;
}