#include <stdio.h>
#include <stdlib.h>
#include <time.h>

int main ( int argc , char ** argv ){

	static const int SIZE = 50;
	
	int A[SIZE] = {0};
	int max_idx = 0;
	int tmp = 0;
	
	int i;
	for(i = 0; i < SIZE; i++){
		srand(clock());
		A[i] = rand() % 100;
	}
	
	for(i = 0; i < SIZE; i++){
		printf("%d ", A[i]);
	}
	printf("\n");
	
	int j;
	for(i = SIZE - 1; i > 1; i--){
		max_idx = 0;
		for(j = 1; j <= i; j++){
			if(A[j] >= A[max_idx]){
				max_idx = j;
			}
		}
		tmp = A[i];
		A[i] = A[max_idx];
		A[max_idx] = tmp;
	}
	
	for(i = 0; i < SIZE; i++){
		printf("%d ", A[i]);
	}
	printf("\n");
	return EXIT_SUCCESS;
}
