C # algorithm ----- (1) Select sorting

Source: Internet
Author: User

 

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.