Advertisement
Guest User

Untitled

a guest
Dec 10th, 2018
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.38 KB | None | 0 0
  1. public struct point
  2. {
  3. public int x, y;
  4. public char c;
  5. };
  6.  
  7. point[,] arr = new point[3, 3];
  8. arr[0, 0].x = 40;
  9. arr[0, 0].y = 40;
  10. arr[0, 0].c = 'R';
  11.  
  12. arr[0, 1].x = 60;
  13. arr[0, 1].y = 40;
  14. arr[0, 1].c = 'R';
  15.  
  16. arr[0, 2].x = 100;
  17. arr[0, 2].y = 40;
  18. arr[0, 2].c = 'R';
  19.  
  20. arr[1, 2].x = 100;
  21. arr[1, 2].y = 60;
  22. arr[1, 2].c = 'R';
  23.  
  24.  
  25. arr[2, 2].x = 100;
  26. arr[2, 2].y = 100;
  27. arr[2, 2].c = 'R';
  28.  
  29.  
  30. Graphics g = this.CreateGraphics();
  31. Pen p = new Pen(Brushes.BlueViolet, 13);
  32. float x1, x2, y1, y2;
  33.  
  34.  
  35. for(int i=0;i<3;i++)
  36. {
  37. for(int j=0;j<3;j++)
  38. {
  39. if(arr[i, j].c == '-')
  40. {
  41. continue;
  42. }
  43.  
  44. x1 = arr[i, j].x; x2 = arr[i, j].x; y1 = arr[i, j].y; y2 = arr[i, j].y;
  45. int temp_i = i, temp_j = j;
  46. while (true)
  47. {
  48. if (temp_i < 3 && temp_j + 1 < 3)
  49. {
  50. if (arr[temp_i, temp_j + 1].c == 'R')
  51. {
  52. x2++;
  53. temp_j++;
  54. arr[temp_i, temp_j].c = '-';
  55. g.DrawLine(p, x1, y1, x2, y2);
  56. Thread.Sleep(5);
  57. }
  58. }
  59.  
  60. else if (temp_i + 1 < 3 && temp_j < 3)
  61. {
  62. if (arr[temp_i + 1, temp_j].c == 'R')
  63. {
  64. y2--;
  65. temp_i++;
  66. arr[temp_i, temp_j].c = '-';
  67. g.DrawLine(p, x1, y1, x2, y2);
  68. Thread.Sleep(5);
  69. }
  70. }
  71. else if (temp_i < 3 && temp_j - 1 < 3)
  72. {
  73. if (arr[temp_i, temp_j - 1].c == 'R')
  74. {
  75. x2--;
  76. temp_j--;
  77. arr[temp_i, temp_j].c = '-';
  78. g.DrawLine(p, x1, y1, x2, y2);
  79. Thread.Sleep(5);
  80. }
  81. }
  82. else if (temp_i - 1 < 3 && temp_j < 3)
  83. {
  84. if (arr[temp_i - 1, temp_j].c == 'R')
  85. {
  86. y2++;
  87. temp_i--;
  88. arr[temp_i, temp_j].c = '-';
  89. g.DrawLine(p, x1, y1, x2, y2);
  90. Thread.Sleep(5);
  91. }
  92. }
  93. else
  94. {
  95. break;
  96. }
  97.  
  98. }
  99. break;
  100. }
  101. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement