Welcome

>>>Welcome to my "CODE BAZAR"
Code marshal
URI online judge
Others
Code marshal
URI online judge
Others
Code marshal
URI online judge
Others

Update ✔✔✔ Upcoming programming book (.pdf) "Programming Contest (data structures and algorithms) by Md. Mahbub Hasan & "Graph Algorithms" by Safayat Asraf "****** Date: 20 March, 2019****Hazrat Ali****

Sunday, 13 November 2016

URI-1042

URI Online Judge | 1042

Simple Sort

Adapted by Neilor Tonin, URI  Brazil
Timelimit: 1
Problem link Click here
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


Solution...


#include <stdio.h>
int main()
{
    int a, b, c, g, m, s, temp;
    scanf("%d %d %d", &a, &b, &c);
    g = a;
    m = b;
    s = c;
    if (g < m){
        temp = g;
        g = m;
        m = temp;
    }
    if (m < s){
        temp = m;
        m = s;
        s = temp;
    }
    if (g < m){
        temp = g;
        g = m;
        m = temp;
    }
    printf("%d\n%d\n%d\n\n%d\n%d\n%d\n",s,m,g,a,b,c);
    return 0;
}


No comments:

Post a Comment