I. Sort the one-dimensional arrays by the selection sorting method,
/* Personal understanding of sorting:
First filter, select the maximum value, and obtain the value and subscript.
The outer loop exchanges the position of the maximum value with the first position of the array.
Filter again from the second position of the array
Swap the location of the largest value with the second location of the array
Until the array is filtered
*/
Ii. Code
Using System; using System. collections. generic; using System. componentModel; using System. data; using System. drawing; using System. linq; using System. text; using System. windows. forms; namespace selectSortArray {public partial class Form1: Form {public Form1 () {InitializeComponent ();} int [] array = {0, 5, 8, 7, 4, 6, 3, 2, 1, 9}; // create an array private void Form1_Load (object sender, EventArgs e) {for (int I = 0; I <array. length; I ++) // display the array in the text box {tb_numfirst.Text + = array [I]. toString () + "" ;}} private void btn_score_Click (object sender, EventArgs e) {tb_new.Clear (); // clear existing display int tem = 0; // used to store the maximum number of int num = 0; // used to store the subscript for (int j = 0; j <array. length-1; j ++) // Save the maximum number to the position and specify it as the switching position without the last {tem = array [j]; // used to store the maximum number num = j; // used to store the subscript for (int I = j + 1; I <array. length-1; I ++) // obtain the maximum number in a group {if (array [I + 1]> tem) {tem = array [I + 1]; // store the maximum number num = I + 1; // store the subscript of the maximum number} array [num] = array [j]; // place the first place in the largest position of the value array [j] = tem; // place the largest number in the first place} for (int I = 0; I <array. length; I ++) // display the array in the text box {tb_new. text + = array [I]. toString () + "";}}}}