# Include "Stdafx. H"
# Include <Iostream>
VoidDirectselectsort (Int*,IntIlen );
VoidSwap (Int*,IntIndex1,IntIndex2 );
VoidPrintarray (IntA [],IntIlen );
Int_ Tmain (IntArgc, _ tchar * argv [])
{
IntArraytosort [] = {20, 7, 3, 4, 25, 15, 29, 12, 4, 1 };
IntN =Sizeof(Arraytosort )/Sizeof(Int);
Printarray (arraytosort, N );
Directselectsort (arraytosort, N );
Printarray (arraytosort, N );
Return0;
}
VoidDirectselectsort (Int*,IntIlen)
{
For(IntI = 0; I <= iLen-2; I ++)
{
IntMin = A [I];
IntImin = I;
For(IntJ = I + 1; j <ilen; j ++)
{
If(A [J] <min)
{
Min = A [J];
Imin = J;
}
}
If(I! = Imin)
{
Swap (A, I, Imin );
}
}
}
VoidSwap (Int*,IntIndex1,IntIndex2)
{
If(Index1! = Index2 &! = NULL)
{
IntTemp = A [index1];
A [index1] = A [index2];
A [index2] = temp;
}
}
VoidPrintarray (IntA [],IntIlen)
{
For(IntI = 0; I <ilen; I ++)
{
STD: cout <A [I] <'';
}
STD: cout <STD: Endl;
}