Código
Los codigos deben ir en etiquetas GeSHi
#include<iostream> using namespace std; void ordenar(); int main(){ int vector[5] = {2,4,5,3,1}; ordenar(vector); for(int i=0; i<5; i++){ cout<<vector[i]<<" "; } return 0; } void ordenar(int v[5]){ int i, n, pos, aux; n= sizeof(v)/sizeof(v[0]); for(i=0; i<5; i++){ pos = i; aux = v[i]; while((pos>0) && v[pos-1]>aux){ v[pos] = v[pos-1]; pos--; } v[pos] = aux; } }