Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Matrixx
- {
- class Program
- {
- static void Main(string[] args)
- {
- int[] sizes = Console.ReadLine().Split(',').Select(int.Parse).ToArray();
- int rows = sizes[0];
- int cols = sizes[1];
- int[,] matrix = new int[rows, cols];
- for (int row = 0; row < rows; row++)
- {
- for (int col = 0; col < cols; col++)
- {
- matrix[row, col] = 100;
- }
- }
- while (true)
- {
- String input = Console.ReadLine();
- if (input == "GAME OVER")
- {
- break;
- }
- int[] data = input.Split(',').Select(int.Parse).ToArray();
- if (data[0] < 0 || data[0] >= rows || data[1] < 0 || data[1] >= cols)
- {
- continue;
- }
- for (int x = -1; x <= 1; x++)
- {
- for (int y = -1; y <= 1; y++)
- {
- if (data[0] + x >= 0 &&
- data[0] + x < rows &&
- data[1] + y >= 0 &&
- data[1] + y < cols)
- {
- if (x == 0 && y == 0)
- {
- matrix[data[0], data[1]] -= data[2];
- }
- else
- {
- /*
- int damage = 0;
- if (data[2] >= 1 && data[2] <= 30)
- {
- damage = 5;
- }
- else if (damage < 70)
- {
- damage = 10;
- }
- else
- {
- damage = (100 * data[2]) / 20;
- }
- matrix[data[0] + x, data[1] + y] -= damage;
- */
- matrix[data[0] + x, data[1] + y] -= 10;
- }
- }
- }
- }
- }
- // print matrix
- for (int row = 0; row < rows; row++)
- {
- for (int col = 0; col < cols; col++)
- {
- Console.Write("{0} ", matrix[row, col]);
- }
- Console.WriteLine();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement