Friday, October 26, 2018

Uri 1042 solution in C | Simple Sort

/*Before seeing the code solution make sure that you have tried enough. Don’t copy- paste the whole code. Find out the logic. If you face any trouble, just inform me in comment.*/

#include<stdio.h>
main()
{
    int a,b,c,min,max,mid;
    scanf("%d%d%d",&a,&b,&c);
    min=a;
    if(b<c&&b<a)
    {
        min=b;
    }
    else if(c<a&&c<b)
    {
        min=c;
    }
    mid=a;
    if(b<a&&b>c||b>a&&b<c)
    {
        mid=b;
    }
    else if(c>a&&c<b||c<a&&c>b)
    {
        mid=c;
    }
    max=a;
    if(b>c&&b>a)
    {
        max=b;
    }
    else if(c>a&&c>b)
    {
        max=c;
    }
    printf("%d\n%d\n%d\n\n",min,mid,max);
    printf("%d\n%d\n%d\n",a,b,c);
    return 0;
}

 //Happy_Coding

1 comment:

  1. Is that okay
    a,b,c=input().split()
    a=int(a)
    b=int(b)
    c=int(c)
    a,b,c= c,a,b
    print(a,b,c)

    ReplyDelete