Problem:
Sorting Three Numbers

Write a program which reads three integers, and prints them in ascending order.

Input

Three integers separated by a single space are given in a line.

Output

Print the given integers in ascending order in a line. Put a single space between two integers.

Constraints

1 ≤ the three integers ≤ 10000

Sample Input 1

3 8 1

Sample Output 1

1 3 8

Solution in C (judge verdict: Time Limit Exceeded)

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

#define NUM 3

void shuf(int []);
int judge(int []);

void shuf(int a[NUM]){
	
	int l = 0;
	int x = 0, y = 0;
	
	x = rand() % 3;
	y = rand() % 3;
	while(x == y) {
		y = rand() % 3;
	}
	
	l = a[x];
	a[x] = a[y];
	a[y] = l;
	
}

int judge(int a[NUM]) {
	
	int flag = 0;
	
	if(a[0] < a[1] && a[1] < a[2])  flag = 1;
	
	return flag;
	
}

int main(int argc, char *argv[]) {
	
	int in[NUM] = {0};
	
	fscanf(stdin, "%d %d %d", in, in+1, in+2);
	
	while(judge(in) == 0) {
		shuf(in);
	}
	
	fprintf(stdout, "%d %d %d\n", in[0], in[1], in[2]);
	
	return 0;

}