You are on page 1of 3

#include<iostream> using namespace std; int main() { int Cantidad,Vector[50],i,j,k,b,Aux,l; cout<<"METODO DE SHELL: "<<endl; cout<<"tingrese la cantida de elementos: ";

cin>>Cantidad; for(i=1;i<=Cantidad;i++) { cout<<" "<<i<<".. ="; cin>>Vector[i]; } b = Cantidad / 2; while(b>0) {

for(i=b+1;i<=Cantidad;i++) { j = i - b; while(j>0) { k = j + b; if(Vector[j]<Vector[k]) j=0; else { Aux = Vector[j]; Vector[j] = Vector[k]; Vector[k] = Aux; } j = j - b; } } b = b / 2; } cout<<endl; cout<<" VECTOR ORDENADO "<<endl; for(i=1;i<=Cantidad;i++) cout<<" "<<Vector[i];

return 0; }

You might also like