Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ConsoleApp23
- {
- class Program
- {
- static void Hanoi (string a, string b, string c, int n)
- {
- if (n == 1) Console.WriteLine("premesti disk ot " + a + " na " + c);
- else
- {
- Hanoi(a, c, b, n - 1);
- Console.WriteLine("premesti disk ot " + a + " na " + c);
- Hanoi(b, a, c, n - 1);
- }
- }
- static void Main(string[] args)
- {
- string a = "A";
- string b = "B";
- string c = "C";
- Hanoi(a, b, c, 4);
- }
- }
- }
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ConsoleApp23
- {
- class Program
- {
- static void Hanoi (string a, string b, string c, int n)
- {
- if (n == 1) Console.WriteLine("premesti disk ot " + a + " na " + c);
- else
- {
- Hanoi(a, c, b, n - 1);
- Console.WriteLine("premesti disk ot " + a + " na " + c);
- Hanoi(b, a, c, n - 1);
- }
- }
- static void Main(string[] args)
- {
- string a = "A";
- string b = "B";
- string c = "C";
- Hanoi(a, b, c, 4);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement