SHOW:
|
|
- or go back to the newest paste.
| 1 | using System; | |
| 2 | using System.Collections.Generic; | |
| 3 | using System.Linq; | |
| 4 | using System.Text; | |
| 5 | using System.Threading.Tasks; | |
| 6 | ||
| 7 | namespace TargetPractice | |
| 8 | {
| |
| 9 | class Program | |
| 10 | {
| |
| 11 | public static bool IsInRectangle(double centerX, double centerY, double radius, | |
| 12 | double x, double y) | |
| 13 | {
| |
| 14 | return x >= centerX - radius && x <= centerX + radius && | |
| 15 | y >= centerY - radius && y <= centerY + radius; | |
| 16 | } | |
| 17 | ||
| 18 | public static bool IsPointInCircle(double centerX, double centerY, | |
| 19 | double radius, double x, double y) | |
| 20 | {
| |
| 21 | if (IsInRectangle(centerX, centerY, radius, x, y)) | |
| 22 | {
| |
| 23 | double dx = centerX - x; | |
| 24 | double dy = centerY - y; | |
| 25 | dx *= dx; | |
| 26 | dy *= dy; | |
| 27 | double distanceSquared = dx + dy; | |
| 28 | double radiusSquared = radius * radius; | |
| 29 | return distanceSquared <= radiusSquared; | |
| 30 | } | |
| 31 | return false; | |
| 32 | } | |
| 33 | static void Main(string[] args) | |
| 34 | {
| |
| 35 | string firstLine = Console.ReadLine(); | |
| 36 | string[] dimensionsArray = firstLine.Split(' ');
| |
| 37 | int rows = int.Parse(dimensionsArray[0]); | |
| 38 | int cols = int.Parse(dimensionsArray[1]); | |
| 39 | string snake = Console.ReadLine(); | |
| 40 | string[] shotParams = Console.ReadLine().Split(' ');
| |
| 41 | int impactRow = int.Parse(shotParams[0]); | |
| 42 | int impactCol = int.Parse(shotParams[1]); | |
| 43 | int radius = int.Parse(shotParams[2]); | |
| 44 | ||
| 45 | char[,] matrix = new char[rows, cols]; | |
| 46 | ||
| 47 | int countLine = -1; | |
| 48 | int countSnakeChar = -1; | |
| 49 | for (int i = rows - 1; i >= 0; i--) | |
| 50 | {
| |
| 51 | countLine++; | |
| 52 | ||
| 53 | if (countLine%2 == 0) | |
| 54 | {
| |
| 55 | ||
| 56 | for (int j = cols - 1; j >= 0; j--) | |
| 57 | {
| |
| 58 | countSnakeChar++; | |
| 59 | if (countSnakeChar == snake.Length) | |
| 60 | {
| |
| 61 | countSnakeChar = 0; | |
| 62 | } | |
| 63 | matrix[i, j] = snake[countSnakeChar]; | |
| 64 | } | |
| 65 | } | |
| 66 | else | |
| 67 | {
| |
| 68 | ||
| 69 | for (int j = 0; j < cols; j++) | |
| 70 | {
| |
| 71 | countSnakeChar++; | |
| 72 | if (countSnakeChar == snake.Length) | |
| 73 | {
| |
| 74 | countSnakeChar = 0; | |
| 75 | } | |
| 76 | matrix[i, j] = snake[countSnakeChar]; | |
| 77 | } | |
| 78 | } | |
| 79 | } | |
| 80 | ||
| 81 | ||
| 82 | ||
| 83 | for (int i = 0; i < rows; i++) | |
| 84 | {
| |
| 85 | for (int j = 0; j < cols; j++) | |
| 86 | {
| |
| 87 | if (IsPointInCircle(impactRow, impactCol, radius, i, j)) | |
| 88 | {
| |
| 89 | matrix[i, j] = ' '; | |
| 90 | } | |
| 91 | } | |
| 92 | ||
| 93 | } | |
| 94 | ||
| 95 | for (int a = 0; a < rows; a++) | |
| 96 | {
| |
| 97 | for (int i = rows - 2; i >= 0; i--) | |
| 98 | {
| |
| 99 | for (int j = 0; j < cols; j++) | |
| 100 | {
| |
| 101 | var ch = matrix[i, j]; | |
| 102 | var under = matrix[i + 1, j]; | |
| 103 | if (under == ' ') | |
| 104 | {
| |
| 105 | matrix[i + 1, j] = ch; | |
| 106 | matrix[i, j] = ' '; | |
| 107 | } | |
| 108 | } | |
| 109 | } | |
| 110 | } | |
| 111 | ||
| 112 | for (int i = 0; i < rows; i++) | |
| 113 | {
| |
| 114 | for (int j = 0; j < cols; j++) | |
| 115 | {
| |
| 116 | Console.Write(matrix[i, j] + ""); | |
| 117 | } | |
| 118 | Console.WriteLine(); | |
| 119 | } | |
| 120 | } | |
| 121 | } | |
| 122 | } |