Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
52.- C++ desde cero 2019🦸‍♂️ [Ejercicio 36.- Ordenamiento método burb…
…uja] Video: https://youtu.be/rjrurmGVSVI
- Loading branch information
1 parent
d359a21
commit 4298200
Showing
2 changed files
with
41 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 not shown.