#include <cstdio>
#include <cstdlib>
#include <ctime>
int main(){
    int i,j,t,max,min;
    int N[100];   
    
    srand(time(0));
    
    for (i=0;i<100;++i) N[i]=rand()%10000+1;
// Hints : find the i-th max and place at the n-i position
// Repeat the task from i=1 to 99
// Hints : the i-th max is in between N[0] and N[100-i]
    for (i=1;i<=99;++i){
    	max=min=0;
        for (j=0;j<=100-i ;++j) if (N[j]>N[max] ) max= j ;

        t= N[100-i] ;
        N[100-i] = N[max];
        N[max] = t ;     
    }
    for (i=0;i<100;++i) printf("%d ",N[i]);
    printf("\n");
    
    for (i=1;i<=99;++i){
    	max=min=0;
        for (j=0;j<=100-i ;++j) if (N[j]<N[max] ) max= j ;

        t= N[100-i] ;
        N[100-i] = N[max];
        N[max] = t ;     
    }
    for (i=0;i<100;++i) printf("%d ",N[i]);
    printf("\n");    
    scanf("%d",i);
    return 0;
}

