Pagini recente » Cod sursa (job #2447020) | Cod sursa (job #2547616) | Cod sursa (job #395604) | Cod sursa (job #1694812) | Cod sursa (job #2022829)
#include <cstdio>
#include <cctype>
#include <algorithm>
#define BUF_SIZE 1 << 17
#define MAXN 500000
int v[MAXN];
int pos = BUF_SIZE, poz = 0;
char buf[BUF_SIZE], fub[BUF_SIZE], c[11];
FILE *fin = fopen("algsort.in", "r"), *fout = fopen("algsort.out", "w");
inline char nextch() {
if (pos == BUF_SIZE) fread(buf, 1, BUF_SIZE, fin), pos = 0;
return buf[pos++];
}
inline int read() {
char ch;
while (!isdigit(ch = nextch()));
int x = ch - '0';
while (isdigit(ch = nextch())) x = 10 * x + ch - '0';
return x;
}
inline void putch(char ch) {
fub[poz++] = ch;
if (poz == BUF_SIZE) fwrite(fub, 1, BUF_SIZE, fout), poz = 0;
}
inline void write(int x) {
int s = 0;
do { c[++s] = x % 10 + '0'; } while ((x /= 10) > 0);
for (; s; s--) putch(c[s]);
}
int main() {
int n = read();
for (int i = 0; i < n; i++)
v[i] = read();
std::sort(v, v + n);
for (int i = 0; i < n; i++) {
write(v[i]);
if (i < n - 1) putch(' ');
else putch('\n');
}
fwrite(fub, 1, poz, fout);
fclose(fin);
fclose(fout);
return 0;
}