Vectores C++

#include <iostream>
using namespace std;

int vector[10];
int i=0,j=0,aux=0;
int main()
{
for (i=0;i<=9;i++)
{
cout<<"\nIngresar elemento al vector ["<<i<<"]";
cin>>vector[i];
}

for (i=1;i<=9;i++)
{
for(j=0;j<9-1;j++)
{
if (vector [j]>vector[j+1])
{
aux=vector[j];
vector[j]=vector[j+1];
vector[j+1]=aux;

}
}
}
for (i=0;i<=9;i++)
{
cout<<vector[i]<<" ";
}
}

Share this

Related Posts

Previous
Next Post »

Buscar en Wikipedia

Resultados de la búsqueda