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