// 4a.cpp
#include <iostream>
#include <iomanip>
using namespace std;
void ordenamiento_de_burbuja(int * p, int n);
void mostrar(int * p, int n);
int main() {
int notas[10];
srand(time(nullptr));
for (int j = 0; j < 10; ++j)
notas[j] = rand()%21;
cout << "Notas generadas:" << endl;
mostrar(notas,10);
ordenamiento_de_burbuja(notas,10);
cout << "Notas ordenadas segun el metodo de ordenamiento de burbuja:" << endl;
mostrar(notas,10);
}
void ordenamiento_de_burbuja(int * p, int n) {
int indice_final = n-1;
if (indice_final == 0) return;
else {
for (int j = 0; j < indice_final; ++j) {
if (p[j] > p[j+1]) {
int aux = p[j];
p[j] = p[j+1];
p[j+1] = aux;
}
}
ordenamiento_de_burbuja(p, n-1);
}
}
void mostrar(int * p, int n) {
for (int j = 0; j < n; ++j) {
cout << setw(4) << p[j];
}
cout << endl;
}