Advertisement
al33kappa

HANOI

May 12th, 2018
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.98 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 WindowsFormsApp4
  12. {
  13. public partial class Form1 : Form
  14. {
  15. public Form1()
  16. {
  17. InitializeComponent();
  18. label2.BackColor = Color.Red;
  19. label1.BackColor = Color.Yellow;
  20. label3.BackColor = Color.Orange;
  21. label4.BackColor = Color.Purple;
  22. label5.BackColor = Color.Blue;
  23. labelCarcas.BackColor = Color.Black;
  24.  
  25. }
  26. int pot1 = 44;
  27. bool flag = true;
  28. Stack<Label> F_stack = new Stack<Label>();
  29. Stack<Label> S_stack = new Stack<Label>();
  30. int i = 2, j = 0;
  31. Label[] massiv;
  32. int[] massivj = new int[4] { -1, -2, -3, -4 };
  33. private void pictureBox1_Click(object sender, EventArgs e)
  34. {
  35.  
  36. }
  37. private void timer1_Tick(object sender, EventArgs e)
  38. {
  39. move_1_2();
  40. }
  41. public void button1_Click(object sender, EventArgs e)
  42. {
  43. timer1.Interval = 2;
  44. F_stack.Push(label1);
  45. F_stack.Push(label2);
  46. F_stack.Push(label3);
  47. //F_stack.Push(label4);
  48. //F_stack.Push(label5);
  49. massiv = new Label[5] { label11, label22, label33, label44, label55 };
  50. /*S_stack.Push(label55);
  51. S_stack.Push(label44);
  52. S_stack.Push(label33);
  53. S_stack.Push(label22);
  54. S_stack.Push(label11);*///�� ��������
  55. timer1.Start();
  56. }
  57. private void Form1_Load(object sender, EventArgs e)
  58. {
  59.  
  60. }
  61. public void move_1_2()
  62. {
  63. if (F_stack.Count == 0)
  64. {
  65. timer1.Stop();
  66. }
  67. else
  68. {
  69. if (F_stack.Peek().Location.X == F_stack.Peek().Location.X && F_stack.Peek().Location.Y >= pot1 && flag)
  70. {
  71. F_stack.Peek().Top -= 4;
  72. }
  73. else if (F_stack.Peek().Location.Y == F_stack.Peek().Location.Y && F_stack.Peek().Location.X < massiv[i].Location.X)
  74. {
  75. F_stack.Peek().Left += 4;
  76. flag = false;
  77. }
  78. else if (F_stack.Peek().Location.X == F_stack.Peek().Location.X && F_stack.Peek().Location.Y <= massiv[j].Location.Y)
  79. {
  80. F_stack.Peek().Top += 4;
  81. }
  82. else
  83. {
  84. S_stack.Push(F_stack.Peek());
  85. F_stack.Pop();
  86. i--;
  87. j++;
  88. flag = true;
  89. }
  90. }
  91. }//move_1_2_end
  92. private public move_1_3()
  93. {
  94.  
  95. }//move_1_3_end
  96. }
  97. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement