Skip to content

Instantly share code, notes, and snippets.

@FelipeGrijo
Created February 24, 2017 20:26
Show Gist options
  • Save FelipeGrijo/9bfe7770218281d31fb321e06ef73f37 to your computer and use it in GitHub Desktop.
Save FelipeGrijo/9bfe7770218281d31fb321e06ef73f37 to your computer and use it in GitHub Desktop.
09) Construa um algoritmo que leia três valores inteiros e os imprima em ordem crescente
//https://gist.github.com/FelipeGrijo
#include <stdio.h>
int main()
{
int Num1,Num2,Num3,x=0;
printf("Exercicio 9\nDigite 3 numeros.\nPrimeiro numero:");
scanf("%d",&Num1);
printf("Segundo numero:");
scanf("%d",&Num2);
printf("Terceiro numero:");
scanf("%d",&Num3);
if(Num1 > Num2){
x=Num1;
Num1=Num2;
Num2=x;
}
if(Num2 <= Num3){
printf("A ordem crescente e: %d %d %d\n",Num1,Num2,Num3);
}
else
{
if(Num1 <= Num3){
printf("A ordem crescente e: %d %d %d\n",Num1,Num3,Num2);
}
else
{
printf("A ordem crescente e: %d %d %d\n",Num3,Num1,Num2);
}
}
system("pause");
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment