Pagini recente » Cod sursa (job #965829) | Cod sursa (job #1570038) | Cod sursa (job #2866319) | Cod sursa (job #918047) | Cod sursa (job #1811851)
#include <bits/stdc++.h>
#define SZ(x) ((int) (x).size())
using namespace std;
const int NMAX = 500000;
template<class Type, int size>
class Prealloc {
private:
Type data[size];
Type* addresses[size];
int available;
public:
Prealloc() {
this->available = size;
int i;
for (i = 0; i < size; ++i) {
this->addresses[i] = &this->data[i];
}
}
Type* newType() {
--this->available;
return this->addresses[this->available];
}
void deleteType(Type* address) {
this->addresses[this->available] = address;
++this->available;
}
};
template<int BUFFSIZE>
class InputReader {
public:
InputReader(const char InputFile[])
: fin(fopen(InputFile, "r")), ptr(BUFFSIZE) {
}
~InputReader() {
fclose(fin);
}
template<class T>
inline InputReader& operator >>(T& x) {
char c;
do {
c = GetChar();
} while (not isdigit(c));
x = 0;
do {
x = (x << 1) + (x << 3) + (c & 207);
c = GetChar();
} while (isdigit(c));
return *this;
}
private:
FILE *fin;
char buff[BUFFSIZE];
int ptr;
inline char GetChar() {
if (ptr == BUFFSIZE) {
fread(buff, 1, BUFFSIZE, fin);
ptr = 0;
}
return buff[ptr++];
}
};
template<int BUFFSIZE>
class PrintWriter {
public:
PrintWriter(const char OutputFile[])
: fout(fopen(OutputFile, "w")), ptr(0) {
}
void flush() {
fwrite(buff, 1, ptr, fout);
ptr = 0;
fflush(fout);
}
~PrintWriter() {
fwrite(buff, 1, ptr, fout);
fclose(fout);
}
inline PrintWriter &operator <<(const char& ch) {
PutChar(ch);
return *this;
}
inline PrintWriter &operator <<(int x) {
int q;
int n = 0; char digs[10];
do {
q = (3435973837LL * x) >> 35;
digs[n++] = x - (q << 1) - (q << 3) + '0';
x = q;
} while (x);
while (n--) {
PutChar(digs[n]);
}
return *this;
}
private:
FILE *fout;
char buff[BUFFSIZE];
int ptr;
inline void PutChar(const char& ch) {
buff[ptr++] = ch;
if (ptr == BUFFSIZE) {
fwrite(buff, 1, BUFFSIZE, fout);
ptr = 0;
}
}
};
int main() {
InputReader<4096> cin("algsort.in");
PrintWriter<4096> cout("algsort.out");
int n; cin >> n;
vector<int> v(n);
for (int i = 0; i < n; i++) {
cin >> v[i];
}
sort(v.begin(), v.end());
for (const int& x : v) {
cout << x << ' ';
}
cout << '\n';
cout.flush();
}