Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Towers of Hanoi
//Title of this code //Rextester.Program.Main is the entry point for your code. Don't change it. using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; namespace Rextester { public class Program { public static void Main(string[] args) { List<int> s = new List<int>(){3,2,1}; List<int> d = new List<int>(); List<int> a = new List<int>(); Move(s.Count, s, d, a, "source", "destination", "aux"); } public static void Move(int how_many, List<int> source, List<int> destination, List<int> aux, string s, string d, string a) { if(how_many == 1) { destination.Add(source.Last()); source.RemoveAt(source.Count-1); Console.WriteLine("Move from {0} to {1}", s, d); return; } else { Move(how_many-1, source, aux, destination, s, a, d); destination.Add(source.Last()); source.RemoveAt(source.Count-1); Console.WriteLine("Move from {0} to {1}", s, d); Move(how_many-1, aux, destination, source, a, d, s); } } } }
run
|
edit
|
history
|
help
0
Kopia
Live tv 2021
Intuit // C# // Lecture_4 // Laba_#2
Simple inheritance
EFDWSDCS
Сортировка массива
Display the pattern like diamond by using c# for loop
Roman Numbers, Sorting through IComparer
Code wall rules
length