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 _05.BlurFilter
- {
- class BlurFilter
- {
- static void Main(string[] args)
- {
- long blurAmount = long.Parse(Console.ReadLine());
- string[] input = Console.ReadLine().Split(' ');
- long rows = long.Parse(input[0]);
- long cols = long.Parse(input[1]);
- long[,] matrix = new long[rows, cols];
- ReadMatrix(rows, cols, matrix);
- string[] target = Console.ReadLine().Split(' ');
- long rowsBlur = long.Parse(target[0]);
- long colsBlur = long.Parse(target[1]);
- //Console.WriteLine();
- long[,] newMatrix = new long[matrix.GetLength(0), matrix.GetLength(1)];
- for (int row = 0; row < matrix.GetLength(0); row++)
- {
- for (int col = 0; col < matrix.GetLength(1); col++)
- {
- if ((row == rowsBlur && col == colsBlur) || (row == rowsBlur - 1 && col == colsBlur - 1)
- || (row == rowsBlur - 1 && col == colsBlur) || (row == rowsBlur - 1 && col == colsBlur + 1)
- || (row == rowsBlur && col == colsBlur - 1) || (row == rowsBlur && col == colsBlur + 1)
- || (row == rowsBlur + 1 && col == colsBlur - 1) || (row == rowsBlur + 1 && col == colsBlur)
- || (row == rowsBlur + 1 && col == colsBlur + 1))
- {
- newMatrix[row, col] = matrix[row, col] + blurAmount;
- }
- else
- {
- newMatrix[row, col] = matrix[row, col];
- }
- }
- }
- PrintMatrix(matrix, newMatrix);
- }
- static void ReadMatrix(long rows, long cols, long[,] matrix)
- {
- for (int row = 0; row < rows; row++)
- {
- long[] cells = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
- for (int col = 0; col < cols; col++)
- {
- matrix[row, col] = cells[col];
- }
- }
- }
- static void PrintMatrix(long[,] matrix, long[,] newMatrix)
- {
- for (int row = 0; row < matrix.GetLength(0); row++)
- {
- for (int col = 0; col < matrix.GetLength(1); col++)
- {
- Console.Write(newMatrix[row, col] + " ");
- }
- Console.WriteLine();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement