Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
radix 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) { namespace ConsoleApplication2 { class Example { private int[] data; private IList<IList<int>> digits = new List<IList<int>>(); private int maxLength = 0; public Example() { for (int i = 0; i < 10; i++) { digits.Add(new List<int>()); } Console.Write("Enter the Number of Records : "); int count = int.Parse(Console.ReadLine()); data = new int[count]; Console.ReadLine(); for (int i = 0; i < count; i++) { Console.Write("Enter Record {0} : ", i + 1); data[i] = int.Parse(Console.ReadLine()); if (maxLength < data[i].ToString().Length) maxLength = data[i].ToString().Length; } } public void RadixSort() { for (int i = 0; i < maxLength; i++) { for (int j = 0; j < data.Length; j++) { int digit = (int)((data[j] % Math.Pow(10, i + 1)) / Math.Pow(10, i)); digits[digit].Add(data[j]); } int index = 0; for (int k = 0; k < digits.Count; k++) { IList<int> selDigit = digits[k]; for (int l = 0; l < selDigit.Count; l++) { data[index++] = selDigit[l]; } } ClearDigits(); } printSortedData(); } private void ClearDigits() { for (int k = 0; k < digits.Count; k++) { digits[k].Clear(); } } public void printSortedData() { Console.WriteLine("The Sorted Numbers are : "); for (int i = 0; i < data.Length; i++) { Console.WriteLine(data[i]); } } static void Main(string[] args) { new Example().RadixSort(); Console.ReadLine(); } } } } } }
run
|
edit
|
history
|
help
0
sdcsvdfcsc
free robux
linked list (add to end and beginning, and looking for cycles based on Floyd's algorithm)
sdfrgthyju8765rb dcd vxs dd
First Test With Coder - 3 digit number into digits
D112
asxsadxsdf
Char To Image
5
dsdsdsdsd