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>
int main(void)
{
  int num;
  int n=0;
  int a,b,c;
  int x[]={a,b,c};
  for(int i=0;i<3;i++){
    scanf("%d",&x[i]);
  }
  while(n<3){
    if(x[n]<x[n+1]){
      continue;
    }else{
      num=x[n+1];
      x[n+1]=x[n];
      x[n]=num;
      if(x[n+1]>x[n+2]){
        num=x[n+2];
        x[n+2]=x[n+1];
        x[n+1]=num;
      } 
    }
    ++n;
  }
  printf(" %d %d %d\n",x[0],x[1],x[2]);
  return 0;
}