URI Online Judge Solution 1042 | Simple Sort - URI 1042 Solution in C,C++,Python

 URI Online Judge Solution  1042 | Simple Sort - URI 1042 Solution in C,C++,Python 

Read three integers and sort them in ascending order. After, print these values in ascending order, a blank line and then the values in the sequence as they were readed.

Input

The input contains three integer numbers.

Output

Present the output as requested above.

Input SampleOutput Sample

7 21 -14

-14
7
21

7
21
-14

-14 21 7

-14
7
21

-14
21
7

URI Online Judge Solution  1041 | Coordinates of a Point - URI 1041 Solution in C,C++,Python :


  URI Problem 1042 Solution in C :   

  URI Online Judge 1042 Solve  in C :                                                                             
#include<stdio.h>

int main(){
    int a,b,c,aux;
    int v[3];
    
    scanf("%d %d %d", &a, &b, &c);
    v[0] = a;
    v[1] = b;
    v[2] = c;
    
    for(int i = 0; i < 3; i++){
            for(int j = 0; j < 3; j++){
                    if(v[i] < v[j]){
                            aux = v[j];
                            v[j] = v[i];
                            v[i] = aux;
                    }
            }
    }
    
    printf("%d\n%d\n%d\n", v[0], v[1], v[2]);
    printf("\n%d\n%d\n%d\n", a, b, c);
    return 0;
}

0 Response to URI Online Judge Solution 1042 | Simple Sort - URI 1042 Solution in C,C++,Python

Post a Comment