Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- int i, j, aux, n=8;
- int vetor[n] = { 4, 2, 6, 8, 1, 3, 7, 5 };
- for(i=1; i<n; i++){
- for (j=0; j<n-i; j++){
- if (vetor[j] > vetor[j+1]){
- aux = vetor[j];
- vetor[j] = vetor[j+1];
- vetor[j+1] = aux;
- }
- }
- }
- cout << "Vetor Ordenado: \n";
- for (i=0; i<n; i++)
- cout << " " << vetor[i];
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement