URI Online Judge | 1042
Sort Simples
Adaptado por Neilor Tonin, URI
Brasil
Timelimit: 1
Leia 3 valores inteiros e ordene-os em ordem crescente. No final, mostre os valores em ordem crescente, uma linha em branco e em seguida, os valores na sequência como foram lidos.
Entrada
A entrada contem três números inteiros.
Saída
Imprima a saída conforme foi especificado.
URI Online Judge | 1042
Simple Sort
Adapted by Neilor Tonin, URI
Brazil
Timelimit: 1
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.
#include <stdio.h>
int main()
{
int num1, num2, num3, cont1, cont2, cont3, comparador;
scanf("%d %d %d", &num1, &num2, &num3);
cont1 = num1;
cont2 = num2;
cont3 = num3;
if (cont1 < cont2)
{
comparador = cont1;
cont1 = cont2;
cont2 = comparador;
}
if (cont2 < cont3)
{
comparador = cont2;
cont2 = cont3;
cont3 = comparador;
}
if (cont1 < cont2)
{
comparador = cont1;
cont1 = cont2;
cont2 = comparador;
}
printf("%d\n%d\n%d\n\n%d\n%d\n%d\n",cont3,cont2,cont1,num1,num2,num3);
return 0;
}
Nenhum comentário:
Postar um comentário