URI Online Judge Solution 1042 Simple Sort – Solution in C, C++, Java, Python and C#

URI Online Judge Solution URI Solution -Beginner

URI Online Judge Solution 1042 Simple Sort – Solution in C, C++, Java, Python and C#

URI Online Judge Solution 1042 | Beginner
URI Problem Link – https://www.urionlinejudge.com.br/judge/en/problems/view/1042

Problem Name: URI – Simple sort
Problem Number : URI – 1042
Online Judge : URI Online Judge Solution
Category: Beginner
Solution Language : C,C plus plus, java, python, c#(c sharp)

URI Online Judge Solution 1042 Simple Sort - Solution in C, C++, Java, Python and C#

URI 1042 Simple Sort Code in C / URI 1042 solution in C:

#include <stdio.h>

void
printInOrder(int a, int b, int c)
{

int
min, mid, max;
if
(a < b && a < c){
min = a;
if
(b < c){
mid = b;
max = c;
}
else{
mid = c;
max = b;
}
}
else if(b < a && b < c){
min = b;
if
(a < c){
mid = a;
max = c;
}
else{
mid = c;
max = a;
}
}
else{
min = c;
if
(a < b){
mid = a;
max = b;
}
else{
mid = b;
max = a;
}
}

printf("%dn%dn%dn", min, mid, max);

}


int
main()
{

int
a, b, c;

scanf("%d %d %d", &a, &b, &c);

printInOrder(a, b, c);
printf("n%dn%dn%dn", a, b, c);

return
0;
}

URI 1042 Simple Sort Code in C++ / URI 1042 solution in CPP:

#include <iostream>
using namespace std;

void
printInOrder(int a, int b, int c)
{

int
min, mid, max;
if
(a < b && a < c){
min = a;
if
(b < c){
mid = b;
max = c;
}
else{
mid = c;
max = b;
}
}
else if(b < a && b < c){
min = b;
if
(a < c){
mid = a;
max = c;
}
else{
mid = c;
max = a;
}
}
else{
min = c;
if
(a < b){
mid = a;
max = b;
}
else{
mid = b;
max = a;
}
}


cout << min << endl << mid << endl << max << endl << endl;

}


int
main()
{

int
a, b, c;

cin >> a >> b >> c;

printInOrder(a, b, c);

cout << a << endl << b << endl << c << endl;

return
0;
}

URI 1042 Simple Sort Code in java/ URI 1042 solution in Java:

import java.io.IOException;
import java.util.Scanner;

public class
Main {

public static
void main(String[] args) throws IOException {


int
X, Y, Z, min1, min2 = 0, min3 = 0;
Scanner input = new Scanner(System.in);
X = input.nextInt();
Y = input.nextInt();
Z = input.nextInt();
min1 = Math.min(X, Math.min(Y, Z));
if
(min1 == X) {
min2 =Math.min(Y, Z);
min3 =Math.max(Y, Z);
}

if
(min1 == Y) {
min2 =Math.min(X, Z);
min3 =Math.max(X, Z);
}

if
(min1 == Z) {
min2 = Math.min(X, Y);
min3 = Math.max(X, Y);
}

System.out.print(min1+"n"+min2+"n"+min3+"nn");
System.out.print(X+"n"+Y+"n"+Z+"n");

}

}

URI 1042 Simple Sort Code in Python / URI 1042 solution in Python:

# -*- coding: utf-8 -*-
#Pegando os nĂºmeros do teclado
entrada = raw_input().split()
#Transformando eles em inteiro
a = int(entrada[0])
b = int(entrada[1])
c = int(entrada[2])

#Colocando todos em uma lista
lista = [a,b,c]

#Ordenando a lista
lista.sort()

#Mostrando os numeros ordenados
print lista[0]
print lista[1]
print lista[2]
print ""

#Mostrando os nĂºmeros como foram digitados
print a
print b
print c

URI Solution 1042 Simple Sort Code / URI 1042 solution in  C# (C Sharp):

Demonstration:

Just implement this in coding. Since having any problem just put a comment below. Thanks

Tags: URI Online Judge Solution, URI OJ Solution list, URI Problems Solution, URI solver, URI all problem solution list, URI Simple sort code in C, URI 1042 Simple Sort code in C++, URI 1042 Simple Sort  solution in C, URI solution, URI 1042 solution in C,URI 1042 solution in C++-CPP,URI 1042 solution in C# (C sharp),URI 1042 Simple Sort solution in Java,URI 1042 solution in Python,

Leave a Reply

Your email address will not be published.