Sortare prin metoda interschimbarii


#include<iostream.h>
void main()
{
int i,j,n,aux,v[20];
cout<<"n=";cin>>n;
for(i=0;i<n;i++)
{
 cout<<"v["<<i<<"]=";
 cin>>v[i];
 }
for(i=0;i<n-1;i++)
for(j=i+1;j<n;j++)
if(v[i]>v[j])
 {aux=v[i];v[i]=v[j];v[j]=aux;}
for(i=0;i<=n-1;i++)
cout<<v[i]<<" ";
}