Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
bubble sort
//Rextester.Program.Main is the entry point for your code. Don't change it. //Compiler version 4.0.30319.17929 for Microsoft (R) .NET Framework 4.5 using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; namespace Rextester { public class Program { public static void Main(string[] args) { Console.Write("Enter number of elements: "); int n = int.Parse(Console.ReadLine()); int[] num = new int[n]; for(int i = 0; i<num.Length;i++) { Console.Write("Enter elements: "); num[i] = int.Parse(Console.ReadLine()); } int temp = 0; for (int x = 0; x < num.Length; x++) { for (int sort = 0; sort < num.Length ; sort++) { if (num[sort] > num[sort + 1]) { temp = num[sort + 1]; num[sort + 1] = num[sort]; num[sort] = temp; } } } foreach(int r in num) { Console.WriteLine(num); } } } }
run
|
edit
|
history
|
help
0
temp1
StackOverflow Generic
Swap adjacent Elements
SDAXXX
Complex
Lesson1
circular linked list
Abstract class by Derived class reference example
Find longest span of characters in string
Jump Search