#include<iostream>
using namespace std;
int min(int A[],int k,int n)
{
int loc,MIN;
MIN=A[k];
loc=k;
for(int j=k+1; j<n; j++)
{
if(A[j]<MIN)
{
MIN=A[j];
loc=j;
}
}
return loc;
}
int main()
{
int A[]={12,54,543,22,56,212,77,3,35,765};
int LOC,k,temp;
for(k=0;k<9;k++)//9 is total values in array
{
LOC=min(A,k,10);
temp=A[k];
A[k]=A[LOC];
A[LOC]=temp;
}
for(k=0; k<10; k++)
{
cout<<A[k]<<"t";
}
return 0;
}
0 Comments