#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++) {
        printf("%d ", A[i]);
    }
}

int main() {
    int A[] = {12, 11, 13, 5, 6, 7};
    int n = sizeof(A) / sizeof(A[0]);
    bubbleSortM(A, n);
    printf("Vetor ordenado: \n");
    printVetor(A, n);
}