Speed up development with full-stack environments for every branch.

Learn More

Ordenar una matriz en C++ de mayor a menor o alrevez (Método Burbuja)

Forked from Hello World C++ Example.

3 Runs 13 Views 2 Copies
Saved

Saved

RBalboa 1

RBalboa
published 2 months ago

    #include <iostream>
    
    using namespace std;
    int main()
    {
      cout << " _____________________________________________________________________________ " << endl << endl;
    	cout << "|          :::::::::      :::     :::        :::::::::   ::::::::      :::    |" << endl;
    	cout << "|         :+:    :+:   :+: :+:   :+:        :+:    :+: :+:    :+:   :+: :+:   |" << endl;
    	cout << "|        +:+    +:+  +:+   +:+  +:+        +:+    +:+ +:+    +:+  +:+   +:+   |" << endl;
    	cout << "|       +#++:++#+  +#++:++#++: +#+        +#++:++#+  +#+    +:+ +#++:++#++:   |" << endl;
    	cout << "|      +#+    +#+ +#+     +#+ +#+        +#+    +#+ +#+    +#+ +#+     +#+    |" << endl;
    	cout << "|     #+#    #+# #+#     #+# #+#        #+#    #+# #+#    #+# #+#     #+#     |" << endl;
    	cout << "|    #########  ###     ### ########## #########   ########  ###     ###      |" << endl;
    	cout << "|_____________________________________________________________________________|" << endl;
    	cout << "|     _     _ _______ _______     ______   _____  ______  _     _ _______     |" << endl;
    	cout << "|     |     | |_____|    |        |_____/ |     | |     ) |_____| |______     |" << endl;
    	cout << "|     |_____| |     |    |        |    |_ |_____| |_____/ |     | |______     |" << endl;
    	cout << "|_____________________________________________________________________________|" << endl << endl;
    	cout << "|      DATE: 3/MAR/2017        TITLE: BUBBLE METHOD         VERSION: V1.0     |" << endl;
    	cout << "|      Special thanks to Joseph for code source. So I don't own this code.    |" << endl;
    	cout << "|_____________________________________________________________________________|" << endl << endl;
    	
    	int vector[50];
    	int tam, i, j, aux;
    
    	cout << "\nIngrese el tamaño del vector ";
    	cin >> tam;
    
    	for (i = 0; i<tam; i++)
    	{
    		cout << "X[" << (i + 1) << "]= ";
    		cin >> vector[i];
    	}
    
    	for (i = 0; i<tam; i++)
    	{
    		for(j=i+1;j<tam;j++)
    		{
    			if (vector[i]<vector[j])
    			{
    				aux = vector[i];
    				vector[i] = vector[j];
    				vector[j] = aux;
    			}
    		}
    	}
    
    	cout << "\nVector ordenado de mayor a menor ";
    
    	for (i = 0;i < tam; i++)
    	{
    		cout << vector[i] << ",";
    	}
    }
    
     
    Please login/signup to get access to the terminal.

    Your session has timed out.

    Dismiss (the page may not function properly).