219,260pages on
this wiki
Add New Page
Discuss this page0 Share
Programa:         Unidad5jercicio02cpp
Fecha:            15/03/2007
Descripción:      Arrasy dinámico.

#include <iostream>
#include <fstream>
#include <cstring>
using namespace std;

void ordena(int * p, int n);
void visualiza(int *p, int n);
void generaValores(int *p, int n);

void main()
        int *p, n;

        cout << "Introduzca el numero de elementos del array: ";
        cin >> n;

        p = new int[n];

        generaValores(p, n);


void visualiza(int *p, int n)
        cout << "Elementos del array " << endl;
        for( int i=0; i < n; i++)
                cout << *(p+i) << endl;

void generaValores(int *p, int n)
        for( int i=0; i < n; i++)
                *(p+i) = rand();

void ordena(int * p, int n)
        int i,j, aux;
        for(i=0; i < n-1; i++)
	        for(j = 1 ;j < n; j++)
	        	if(*(p+j-1) > *(p+j))
        			aux = *(p+j);
	        		*(p+j) = *(p+j-1);
		        	*(p+j-1) = aux;

Ad blocker interference detected!

Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.

Also on Fandom

Random wikia