Hi! Dear friends, C # Will be the preferred language for network development in the future. I used C # To develop a selection sorting algorithm. Hope to bring some benefits to learners of C # language.
Don't forget, it takes a lot of effort to learn data structures and algorithms to learn languages.
Using System;
Public class SelectionSorter
{
// Public enum comp {COMP_LESS, COMP_EQUAL, COMP_GRTR };
Private int min;
// Private int m = 0;
Public void Sort (int [] list)
{
For (int I = 0; I <list. Length-1; ++ I)
{
Min = I;
For (int j = I + 1; j <list. Length; ++ j)
{
If (list [j] <list [min])
Min = j;
}
Int t = list [min];
List [min] = list [I];
List [I] = t;
// Console. WriteLine ("{0}", list [I]);
}
}
}
Public class MainClass
{
Public static void Main ()
{
Int [] iArrary = new int };
SelectionSorter ss = new SelectionSorter ();
Ss. Sort (iArrary );
For (int m = 0; m <= 13; m ++)
Console. WriteLine ("{0}", iArrary [m]);
}
}
Compiled successfully.