U A C M

¿Quieres reaccionar a este mensaje? Regístrate en el foro con unos pocos clics o inicia sesión para continuar.
U A C M

Universidad Autónoma de la Ciudad de México


    ALGORITMO DE LA BURBUJA (Arreglos #4)

    Krlos
    Krlos
    Admin


    Mensajes : 72
    Fecha de inscripción : 11/05/2011

    ALGORITMO DE LA BURBUJA (Arreglos #4) Empty ALGORITMO DE LA BURBUJA (Arreglos #4)

    Mensaje  Krlos Lun Mayo 23, 2011 2:32 pm

    //Programa Algoritmo de la burbuja ARREGLOS #4 By Carlos E. López

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

    int main()
    {
    int a[]={20,5,4,2,12};
    int aux;
    int pasada;
    int indice;
    textbackground(BLUE);
    textcolor(WHITE);
    clrscr();
    printf("\n\n\t ALGORITMO DE LA BURBUJA \n\n");
    for(pasada=1;pasada<=5;pasada++)
    {
    for(indice=0;indice<5;indice++)
    {
    if(a[indice]>a[indice+1])
    {
    aux=a[indice];
    a[indice]=a[indice+1];
    a[indice+1]=aux;
    }
    }
    }




    for(indice=0;indice<5;indice++)
    {
    textcolor(WHITE);
    printf("\t\t %d \n",a[indice]);
    }
    getch();
    return 0;
    }

      Fecha y hora actual: Dom Mayo 19, 2024 4:13 am