#include <iostream>
template< typename T > void get( T a[], int n )
{
std::cout << "enter " << n << " array elements: " ;
for( int i = 0 ; i < n ; ++i ) std::cin >> a[i] ;
}
template< typename T > void sort( T a[], int n )
{
for( int i=0 ; i<n ; ++i )
{
for( int j=i+1 ; j<n ; ++j )
{
if( a[j] < a[i] )
{
int temp = a[i] ;
a[i] = a[j] ;
a[j] = temp ;
}
}
}
}
template< typename T > void display( const T a[], int n )
{
std::cout << "the sorted array: " ;
for( int i = 0 ; i < n ; ++i ) std::cout << a[i] << ' ' ;
std::cout << '\n' ;
}
int main()
{
constexpr int N = 5 ;
int array[N] = {0} ;
get( array, N ) ;
sort( array, N ) ;
display( array, N ) ;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgoKdGVtcGxhdGU8IHR5cGVuYW1lIFQgPiB2b2lkIGdldCggVCBhW10sIGludCBuICkKewogICAgc3RkOjpjb3V0IDw8ICJlbnRlciAiIDw8IG4gPDwgIiBhcnJheSBlbGVtZW50czogIiA7CiAgICBmb3IoIGludCBpID0gMCA7IGkgPCBuIDsgKytpICkgc3RkOjpjaW4gPj4gYVtpXSA7Cn0KCnRlbXBsYXRlPCB0eXBlbmFtZSBUID4gdm9pZCBzb3J0KCBUIGFbXSwgaW50IG4gKQp7CiAgICBmb3IoIGludCBpPTAgOyBpPG4gOyArK2kgKQogICAgewogICAgICAgIGZvciggaW50IGo9aSsxIDsgajxuIDsgKytqICkKICAgICAgICB7CiAgICAgICAgICAgIGlmKCBhW2pdIDwgYVtpXSApCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIGludCB0ZW1wID0gYVtpXSA7CiAgICAgICAgICAgICAgICBhW2ldID0gYVtqXSA7CiAgICAgICAgICAgICAgICBhW2pdID0gdGVtcCA7CiAgICAgICAgICAgIH0KICAgICAgICB9CiAgICB9Cn0KCnRlbXBsYXRlPCB0eXBlbmFtZSBUID4gdm9pZCBkaXNwbGF5KCBjb25zdCBUIGFbXSwgaW50IG4gKQp7CiAgICBzdGQ6OmNvdXQgPDwgInRoZSBzb3J0ZWQgYXJyYXk6ICIgOwogICAgZm9yKCBpbnQgaSA9IDAgOyBpIDwgbiA7ICsraSApIHN0ZDo6Y291dCA8PCBhW2ldIDw8ICcgJyA7CiAgICBzdGQ6OmNvdXQgPDwgJ1xuJyA7Cn0KCmludCBtYWluKCkKewogICAgY29uc3RleHByIGludCBOID0gNSA7CiAgICBpbnQgYXJyYXlbTl0gPSB7MH0gOwogICAgZ2V0KCBhcnJheSwgTiApIDsKICAgIHNvcnQoIGFycmF5LCBOICkgOwogICAgZGlzcGxheSggYXJyYXksIE4gKSA7Cn0K