Pagini recente » Cod sursa (job #2201289) | Cod sursa (job #553914) | Cod sursa (job #2922802) | Monitorul de evaluare | Cod sursa (job #1724552)
#include <cstdio>
#include <cctype>
#include <algorithm>
using namespace std;
constexpr int MAX_N = 500000;
constexpr int BUFFSIZE = (1 << 13);
inline char getChar() {
static char buff[BUFFSIZE];
static int pos = 0;
if (__builtin_expect(pos == BUFFSIZE, 0)) {
fread(buff, 1, BUFFSIZE, stdin);
pos = 0;
}
return buff[pos++];
}
inline int readInt() {
int q = 0;
char c;
do {
c = getChar();
} while (!isdigit(c));
do {
q = (q << 1) + (q << 3) + (c - '0');
c = getChar();
} while (isdigit(c));
return q;
}
char buf[BUFFSIZE];
int ptr = 0;
inline void putChar(const char &ch) {
buf[ptr++] = ch;
if (__builtin_expect(ptr == BUFFSIZE, 0)) {
fwrite(buf, 1, BUFFSIZE, stdout);
ptr = 0;
}
}
inline void writeInt(int x) {
char digs[10];
int n = 0, q;
do {
q = x / 10;
digs[n++] = x - (q << 1) - (q << 3) + '0';
x = q;
} while (x);
while (n--) {
putChar(digs[n]);
}
putChar(' ');
}
int v[MAX_N];
int main() {
freopen("algsort.in", "r", stdin);
freopen("algsort.out", "w", stdout);
int n = readInt();
for (int i = 0; i < n; i += 1) {
v[i] = readInt();
}
fclose(stdin);
sort(v, v + n);
for (int i = 0; i < n; i += 1) {
writeInt(v[i]);
}
fwrite(buf, 1, ptr, stdout);
fclose(stdout);
return 0;
}