#include <stdio.h>
#include <stdbool.h>
void bubbleSortM(int A[], int n) {
for (int i = 1; i < n; i++) {
bool troca = 0;
for (int j = n - 1; j >= i; j--) {
if (A[j - 1] > A[j]) {
int aux = A[j - 1];
A[j - 1] = A[j];
A[j] = aux;
troca = 1;
}
}
if (!troca) {
return;
}
}
}
void printVetor(int A[], int size) {
for (int i = 0; i < size; i++) {
}
}
int main() {
int A[] = {12, 11, 13, 5, 6, 7};
int n = sizeof(A) / sizeof(A[0]);
bubbleSortM(A, n);
printVetor(A, n);
}
I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxzdGRib29sLmg+Cgp2b2lkIGJ1YmJsZVNvcnRNKGludCBBW10sIGludCBuKSB7ICAKICAgIGZvciAoaW50IGkgPSAxOyBpIDwgbjsgaSsrKSB7CiAgICAgICAgYm9vbCB0cm9jYSA9IDA7CgogICAgICAgIGZvciAoaW50IGogPSBuIC0gMTsgaiA+PSBpOyBqLS0pIHsgIAogICAgICAgICAgICBpZiAoQVtqIC0gMV0gPiBBW2pdKSB7CiAgICAgICAgICAgICAgICBpbnQgYXV4ID0gQVtqIC0gMV07CiAgICAgICAgICAgICAgICBBW2ogLSAxXSA9IEFbal07CiAgICAgICAgICAgICAgICBBW2pdID0gYXV4OwogICAgICAgICAgICAgICAgdHJvY2EgPSAxOwogICAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIGlmICghdHJvY2EpIHsKICAgICAgICAgICAgcmV0dXJuOwogICAgICAgIH0KICAgIH0KfQoKdm9pZCBwcmludFZldG9yKGludCBBW10sIGludCBzaXplKSB7CiAgICBmb3IgKGludCBpID0gMDsgaSA8IHNpemU7IGkrKykgewogICAgICAgIHByaW50ZigiJWQgIiwgQVtpXSk7CiAgICB9Cn0KCmludCBtYWluKCkgewogICAgaW50IEFbXSA9IHsxMiwgMTEsIDEzLCA1LCA2LCA3fTsKICAgIGludCBuID0gc2l6ZW9mKEEpIC8gc2l6ZW9mKEFbMF0pOwogICAgYnViYmxlU29ydE0oQSwgbik7CiAgICBwcmludGYoIlZldG9yIG9yZGVuYWRvOiBcbiIpOwogICAgcHJpbnRWZXRvcihBLCBuKTsKfQ==