Advertisement
al33kappa

hanoi part1

May 15th, 2018
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.52 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10.  
  11. namespace Idon_tevenknow
  12. {
  13. public partial class Form1 : Form
  14. {
  15. public Form1()
  16. {
  17. InitializeComponent();
  18. }
  19. bool flag = true;
  20. Stack<Label> FirstStack = new Stack<Label>();
  21. Stack<Label> SecondStack = new Stack<Label>();
  22. Stack<Label> ThirdStack = new Stack<Label>();
  23. int pol = 427;
  24. int potolok1 = 70;
  25. int ukaz1 = 3, ukaz2 = 0, ukaz3 = 0;
  26. private void button1_Click(object sender, EventArgs e)
  27. {
  28. FirstStack.Push(label1);
  29. FirstStack.Push(label2);
  30. FirstStack.Push(label3);
  31. timer1.Interval = 10;
  32. timer1.Start();
  33. }
  34. public void HB(int n, int x, int y, int z)
  35. {
  36. if (n != 0)
  37. {
  38. HB(n - 1, x, z, y);
  39. listBox1.Items.Add($"{x} -> {y}");
  40. HB(n - 1, z, y, x);
  41. }
  42. }
  43.  
  44. private void Form1_Load(object sender, EventArgs e)
  45. {
  46. HB(3, 1, 2, 3);
  47. }
  48.  
  49. public void moving()
  50. {
  51. if (FirstStack.Count == 0)
  52. {
  53. timer1.Stop();
  54. }
  55. else
  56. {
  57. int potolok2 = (label6.Location.X - (FirstStack.Peek().Width / 2));
  58. if (FirstStack.Peek().Location.X == FirstStack.Peek().Location.X && FirstStack.Peek().Location.Y > potolok1 && flag) FirstStack.Peek().Top -= 5;
  59. else if (FirstStack.Peek().Location.Y == FirstStack.Peek().Location.Y && FirstStack.Peek().Location.X < potolok2)
  60. {
  61. FirstStack.Peek().Left += 5;
  62. flag = false;
  63. }
  64. else if (FirstStack.Peek().Location.X > potolok2 && FirstStack.Peek().Bottom + (FirstStack.Peek().Height + FirstStack.Peek().Height / 2) < 427) FirstStack.Peek().Top += 5;
  65. else
  66. {
  67. SecondStack.Push(FirstStack.Peek());
  68. FirstStack.Pop();
  69. textBox1.Text = label3.Location.X + " " + label3.Location.Y.ToString();
  70. }
  71. }
  72.  
  73. }
  74. private void timer1_Tick(object sender, EventArgs e)
  75. {
  76. moving();
  77. }
  78. }
  79. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement