Skip to content

Commit

Permalink
52.- C++ desde cero 2019🦸‍♂️ [Ejercicio 36.- Ordenamiento método burb…
Browse files Browse the repository at this point in the history
…uja]

Video:
https://youtu.be/rjrurmGVSVI
  • Loading branch information
programadornovato committed Apr 3, 2020
1 parent d359a21 commit 4298200
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions ejercicios/eje36OrdenamientoBurbuja.cpp
@@ -0,0 +1,41 @@
/*
Pedir al humano que ingresar 5 nĂşmeros.
Ordenar los nĂşmeros.
Mostrar los nĂşmeros de forma ascendente.
Mostrar los nĂşmeros de forma descendente.
*/
#include <iostream>

int main(){
int numeros[5],aux;
std::cout<<"Humano inresa 5 numeros (en el pinche orden que quieras):\n";
for (int i = 0; i < 5; i++)
{
std::cout<<"Ingresa el numero "<<i+1<<": ";
std::cin>>numeros[i];
}
for (int i = 0; i < 5; i++)
{
for (int j = 0; j < 4; j++)
{
if(numeros[j]>numeros[j+1]){
aux=numeros[j];
numeros[j]=numeros[j+1];
numeros[j+1]=aux;
}
}
}
std::cout<<"Humano aqui estan tus pinches numeros (ordenados de forma acedente):\n";
for (int i = 0; i < 5; i++)
{
std::cout<<numeros[i]<<"\n";
}
std::cout<<"Humano aqui estan tus pinches numeros (ordenados de forma decendente):\n";
for (int i = 4; i >= 0; i--)
{
std::cout<<numeros[i]<<"\n";
}

system("pause");
return 0;
}
Binary file added ejercicios/eje36OrdenamientoBurbuja.exe
Binary file not shown.

0 comments on commit 4298200

Please sign in to comment.