Run Code
|
API
|
Code Wall
|
Users
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Blog
towers of hanoi
//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) { char startPeg = 'A'; char endPeg = 'C'; char tempPeg = 'B'; int totalDisks = 3; solveTowers(totalDisks, startPeg, endPeg, tempPeg); } private static void solveTowers(int n, char startPeg, char endPeg, char tempPeg) { if (n > 0) { solveTowers(n - 1, startPeg, tempPeg, endPeg); Console.WriteLine("Move disk from " + startPeg + ' ' + endPeg); solveTowers(n - 1, tempPeg, endPeg, startPeg); } } } }
run
|
edit
|
history
|
help
0
Please
log in
to post a comment.
WebScrape using Regex
Interface with same methods
Non-User input - Random Controlled - Guessing Game
Prime Fibonacci
file Info and File Stream
Pet Name Generator
HourCouter
Namespaces multiple
Pramod
filter distinct items from the array without builtin function - Seeni
stackse - search stackoverflow differently
Please log in to post a comment.