sábado, 21 de octubre de 2017

if 4

Programa Utilizando el "if" donde compara 3 numeros dados por el usuario y te dice cual es el mayor.


#include <stdio.h>
#include <stdlib.h>
#include <conio.h>

int main()
{
    int n1,n2,n3;
    int aux;

    printf("Dame un primer numero\n");
    scanf("%d",&n1);
    printf("\nDame un segundo numero\n");
    scanf("%i",&n2);
    printf("\nDame un tercer numero\n");
    scanf("%i",&n3);

    if (n1<n2)
    {
        if (n1<n3)
        {

        }else
        {
            aux=n3;
            n3=n1;
            n1=aux;
        }
    }else
    {
        aux=n1;
        n1=n2;
        n2=aux;

        if(n2<n3)
        {

        }else
        {
            aux=n2;
            n2=n3;
            n3=aux;

            if(n1<n2)
            {

            }else
            {
                aux=n1;
                n1=n2;
                n2=aux;
            }
        }
    }
    printf("\n%i %i %i\n",n1,n2,n3);

    getch();




    return 0;
}


No hay comentarios:

Publicar un comentario

Cadenas

Programa para copiar, comparar y guardar cadenas. #include <stdio.h> #include <stdlib.h> #include <conio.h> #include...