Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
C# Bubble Sort
//Rextester.Program.Main is the entry point for your code. Don't change it. //Microsoft (R) Visual C# Compiler version 2.9.0.63208 (958f2354) using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; namespace Rextester { public class Program { public static void Main(string[] args) { int[] arr = { 5, 8, 1, 8, 4, 5, 6, 5, 4 }; Console.WriteLine("Bubble Sort"); Console.Write("Start array: "); arr.ToList().ForEach(x => Console.Write(x + " ")); //sort int temp; for(int i = 0; i < arr.Length - 1; i++) { for(int j = 0; j < arr.Length - (1 + i); j++) { if(arr[j] > arr[j + 1]) { temp = arr[j + 1]; arr[j + 1] = arr[j]; arr[j] = temp; } } } Console.Write("\nSorted array: "); arr.ToList().ForEach(x => Console.Write(x + " ")); } } }
run
|
edit
|
history
|
help
0
Великий и могучий РУСЯЗ
First Test With Coder - 3 digit number into digits
dfdfd
assignment no.3.cs
Plt-D v.0.9.4
random number generator
String to Decimal CSHARP
DaysOfYear
OBJ Good Start
asxasxdf