/*
Copyright 2011 Marek "p2004a" Rusinowski
Quick sort
*/
#include <cstdio>
#define MAXN 1000000
int array[ MAXN] ;
void sort( int * begin, int * end) {
if ( begin + 1 >= end) return ;
int cur = * begin, * front = begin + 1 , * back = end - 1 ;
while ( front <= back) {
if ( * back <= cur) {
int tmp = * back;
* back = * front;
* front = tmp;
} else {
-- back;
}
if ( * front <= cur) {
* ( front - 1 ) = * front;
++ front;
}
}
* ( front - 1 ) = cur;
sort( begin, front - 1 ) ;
sort( front, end) ;
}
int main( ) {
int n;
scanf ( "%d" , & n) ;
for ( int i = 0 ; i < n; ++ i) {
scanf ( "%d" , & array[ i] ) ;
}
sort( array, array + n) ;
for ( int i = 0 ; i < n; ++ i) {
printf ( "%d " , array[ i] ) ;
}
printf ( "\n " ) ;
return 0 ;
}
LyoKICBDb3B5cmlnaHQgMjAxMSBNYXJlayAicDIwMDRhIiBSdXNpbm93c2tpCiAgUXVpY2sgc29ydAoqLwojaW5jbHVkZSA8Y3N0ZGlvPgoKI2RlZmluZSBNQVhOIDEwMDAwMDAKCmludCBhcnJheVtNQVhOXTsKCnZvaWQgc29ydChpbnQgKmJlZ2luLCBpbnQgKmVuZCkgewogIGlmIChiZWdpbiArIDEgPj0gZW5kKSByZXR1cm47CiAgaW50IGN1ciA9ICpiZWdpbiwgKmZyb250ID0gYmVnaW4gKyAxLCAqYmFjayA9IGVuZCAtIDE7CiAgd2hpbGUgKGZyb250IDw9IGJhY2spIHsKICAgIGlmICgqYmFjayA8PSBjdXIpIHsKICAgICAgaW50IHRtcCA9ICpiYWNrOwogICAgICAqYmFjayA9ICpmcm9udDsKICAgICAgKmZyb250ID0gdG1wOwogICAgfSBlbHNlIHsKICAgICAgLS1iYWNrOwogICAgfQogICAgaWYgKCpmcm9udCA8PSBjdXIpIHsKICAgICAgKihmcm9udCAtIDEpID0gKmZyb250OwogICAgICArK2Zyb250OwogICAgfQogIH0KICAqKGZyb250IC0gMSkgPSBjdXI7CiAgc29ydChiZWdpbiwgZnJvbnQgLSAxKTsKICBzb3J0KGZyb250LCBlbmQpOwp9CgppbnQgbWFpbigpIHsKICBpbnQgbjsKICBzY2FuZigiJWQiLCAmbik7CiAgZm9yIChpbnQgaSA9IDA7IGkgPCBuOyArK2kpIHsKICAgIHNjYW5mKCIlZCIsICZhcnJheVtpXSk7CiAgfQogIHNvcnQoYXJyYXksIGFycmF5ICsgbik7CiAgZm9yIChpbnQgaSA9IDA7IGkgPCBuOyArK2kpIHsKICAgIHByaW50ZigiJWQgIiwgYXJyYXlbaV0pOwogIH0KICBwcmludGYoIlxuIik7CiAgcmV0dXJuIDA7Cn0K
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:34: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result
prog.cpp:36: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result
stdout