bool sorted; do { sorted = true; for (int i = 1; i < n; i++) if (v[i] > v[i + 1]) { int aux = v[i]; v[i] = v[i + 1]; v[i + 1] = aux; sorted = false; } } while (!sorted);