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

Online Judge: URI Online Judge

Problem Name: Simple Sort

#### URI 1042 solution in C language:

#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("%d\n%d\n%d\n", min, mid, max);

}

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

printInOrder(a, b, c);
printf("\n%d\n%d\n%d\n", a, b, c);
return 0;
}

#### URI 1042 solution in C++ language:

#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 solution in JAVA language:

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+"\n\n");
System.out.print(X+"\n"+Y+"\n"+Z+"\n");
}
}

#### URI 1042 solution in Python language:

# -*- coding: utf-8 -*-
#Transformando eles em inteiro

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

#Ordenando a lista
lista.sort()

print lista[0]
print lista[1]
print lista[2]
print ""

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

Explanation: Check this simple sort solution in different language of URI online judge

## URI OJ Solution 1001 || Simple summation Problem Solution

URI 1001 problem solution in C, Java programming language:

URI 1001 problem solution in C language:

#include<stdio.h>
int main()
{
int A,B,X;
scanf("%d %d", &A, &B);
X=A+B;

printf("X = %d\n",X);

return 0;
}

URI 1001 problem solution in Java programming language:

import java.util.Scanner;
public class Main {
public static void main(String[] args) {

int A, B, X;
Scanner sc = new Scanner(System.in);
A = sc.nextInt();                     //take input for A
B = sc.nextInt();                    //take input for  B
X = A + B;                           //Basic summation X = A + B
System.out.print("X = "+X+"\n");    //Hardly advised to give \n at last

}

}

URI 1001 problem solution in C++ programming language:

#include <iostream>
using namespace std;

int main() {
int A, B, X;
cin >> A >> B;                //take input for A and B
X = A + B;                   //Basic summation X = A + B
cout << "X = " << X << endl;//Print X in given format and endl is endline or it works linke "\n" in c and java
return 0;
}

URI 1001 problem solution in Python programming language:

a = input()
b = input()
X = a + b

print "X = %i" % X

URI Online judge problem 1001 simple explanation:

• Just take two variables or take three variables.
• Take input for two variables
• Store the summation of these two variables to third one
• print the third variable result as the above format.

Note:

Since you are reading this, you are a beginner level programmer. So please focus the presentation and format how they wants data from you. Most beginner programmers, get error for presentation and so on.