Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public struct point
- {
- public int x, y;
- public char c;
- };
- point[,] arr = new point[3, 3];
- arr[0, 0].x = 40;
- arr[0, 0].y = 40;
- arr[0, 0].c = 'R';
- arr[0, 1].x = 60;
- arr[0, 1].y = 40;
- arr[0, 1].c = 'R';
- arr[0, 2].x = 100;
- arr[0, 2].y = 40;
- arr[0, 2].c = 'R';
- arr[1, 2].x = 100;
- arr[1, 2].y = 60;
- arr[1, 2].c = 'R';
- arr[2, 2].x = 100;
- arr[2, 2].y = 100;
- arr[2, 2].c = 'R';
- Graphics g = this.CreateGraphics();
- Pen p = new Pen(Brushes.BlueViolet, 13);
- float x1, x2, y1, y2;
- for(int i=0;i<3;i++)
- {
- for(int j=0;j<3;j++)
- {
- if(arr[i, j].c == '-')
- {
- continue;
- }
- x1 = arr[i, j].x; x2 = arr[i, j].x; y1 = arr[i, j].y; y2 = arr[i, j].y;
- int temp_i = i, temp_j = j;
- while (true)
- {
- if (temp_i < 3 && temp_j + 1 < 3)
- {
- if (arr[temp_i, temp_j + 1].c == 'R')
- {
- x2++;
- temp_j++;
- arr[temp_i, temp_j].c = '-';
- g.DrawLine(p, x1, y1, x2, y2);
- Thread.Sleep(5);
- }
- }
- else if (temp_i + 1 < 3 && temp_j < 3)
- {
- if (arr[temp_i + 1, temp_j].c == 'R')
- {
- y2--;
- temp_i++;
- arr[temp_i, temp_j].c = '-';
- g.DrawLine(p, x1, y1, x2, y2);
- Thread.Sleep(5);
- }
- }
- else if (temp_i < 3 && temp_j - 1 < 3)
- {
- if (arr[temp_i, temp_j - 1].c == 'R')
- {
- x2--;
- temp_j--;
- arr[temp_i, temp_j].c = '-';
- g.DrawLine(p, x1, y1, x2, y2);
- Thread.Sleep(5);
- }
- }
- else if (temp_i - 1 < 3 && temp_j < 3)
- {
- if (arr[temp_i - 1, temp_j].c == 'R')
- {
- y2++;
- temp_i--;
- arr[temp_i, temp_j].c = '-';
- g.DrawLine(p, x1, y1, x2, y2);
- Thread.Sleep(5);
- }
- }
- else
- {
- break;
- }
- }
- break;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement