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 BlurFilter
- {
- class Program
- {
- static void Main(string[] args)
- {
- int blur_amount = int.Parse(Console.ReadLine());
- int[] d = Array.ConvertAll(Console.ReadLine().Split(' '), s => int.Parse(s));
- var matrix = new int[d[0], d[1]];
- for (var i = 0; i < d[0]; i++)
- {
- var line = Console.ReadLine();
- var spl = line.Split(' ');
- if (spl.Length != d[1]) {
- throw new FormatException();
- }
- for (var j = 0; j < d[1]; j++)
- matrix[i, j] = int.Parse(spl[j]);
- }
- var coords = Console.ReadLine().Split(' ');
- if (coords.Length != 2) {
- throw new FormatException();
- }
- matrix = DoTheMath(matrix, coords, blur_amount);
- GetStatus(matrix);
- }
- public static int[,] DoTheMath(int[,] matrix, string[] coords, int blur_amount)
- {
- for (int row = 0; row < matrix.GetLength(0); row++)
- {
- for (int col = 0; col < matrix.GetLength(1); col++)
- {
- if (row == int.Parse(coords[0]) && col == int.Parse(coords[1]))
- {
- matrix[row, col] += blur_amount;
- matrix[row, col - 1] += blur_amount;
- matrix[row - 1, col - 1] += blur_amount;
- matrix[row - 1, col] += blur_amount;
- matrix[row - 1, col + 1] += blur_amount;
- matrix[row, col + 1] += blur_amount;
- matrix[row + 1, col + 1] += blur_amount;
- matrix[row + 1, col] += blur_amount;
- matrix[row + 1, col - 1] += blur_amount;
- }
- }
- }
- return matrix;
- }
- public static void GetStatus(int[,] matrix) {
- for (int i = 0; i < matrix.GetLength(0); i++)
- {
- for (int a = 0; a < matrix.GetLength(1); a++)
- {
- Console.Write("{0} ", matrix[i, a]);
- }
- Console.WriteLine();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement