C # Bubble Sorting Algorithm,
Two types of data are used: a generic List and a data int []. Record it as a note during your learning process.
Using System; using System. collections. generic; using System. linq; using System. text; using System. threading. tasks; namespace Bubble Sorting Algorithm {class Program {static void Main (string [] args) {List <int> _ list = new List <int> () {29, 20, 49, 84, 3, 48, 86, 95, 69, 28}; Bubble (_ list); foreach (var item in _ list) {Console. writeLine (item);} int [] bortargs = {29, 20, 49, 84, 3, 48, 86, 95, 69, 28}; Bubble (bortargs ); foreach (var article in bortargs) {Console. writeLine (article);} Console. readKey ();} static void Bubble (List <int> list) {int temp = 0; for (int I = list. count; I> 0; I --) {for (int j = 0; j <I-1; j ++) {if (list [j]> list [j + 1]) {temp = list [j]; list [j] = list [j + 1]; list [j + 1] = temp ;}}} static void Bubble (int [] args) {int temp = 0; for (int I = args. length; I> 0; I --) {for (int j = 0; j <I-1; j ++) {if (args [j]> args [j + 1]) {temp = args [j]; args [j] = args [j + 1]; args [j + 1] = temp ;}}}}}}
View Code