Skip to content

Instantly share code, notes, and snippets.

@jmramirezpro
Last active March 16, 2016 18:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jmramirezpro/6bfccd87042a33dd882e to your computer and use it in GitHub Desktop.
Save jmramirezpro/6bfccd87042a33dd882e to your computer and use it in GitHub Desktop.
/*
* OrdenaNumeros.c
* Ejercicios del Podcast Codigo Fuente - Programa 026
* Realizar un programa que pida 3 números por la entrada estándar y los muestre
* en pantalla ordenadores de menor a mayor en líneas distintas. Podéis usar las
* estructuras de control que más os convengan.
* Creado el 16 de mar. de 2016
* Author: jmramirez
*/
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
int num1,num2,num3;
printf("Introduce el número 1: ");
scanf("%d",&num1);
printf("Introduce el número 2: ");
scanf("%d",&num2);
printf("Introduce el número 3: ");
scanf("%d",&num3);
if (num1<num2 && num1<num3) {
if (num2<num3){
printf("%d\n",num1);
printf("%d\n",num2);
printf("%d\n",num3);
}else{
printf("%d\n",num1);
printf("%d\n",num3);
printf("%d\n",num2);
}
}else if (num2<num1 && num2<num3){
if (num1<num3){
printf("%d\n",num2);
printf("%d\n",num1);
printf("%d\n",num3);
}else{
printf("%d\n",num2);
printf("%d\n",num3);
printf("%d\n",num1);
}
}else if (num3<num1 && num3<num2){
if (num1<num2){
printf("%d\n",num3);
printf("%d\n",num1);
printf("%d\n",num2);
}else{
printf("%d\n",num3);
printf("%d\n",num2);
printf("%d\n",num1);
}
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment