fbinnzhivko

05.00 Wave Bits

Apr 21st, 2016
260
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.88 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. class Program
  4. {
  5.     static void Main()
  6.     {
  7.         var blurAmount = int.Parse(Console.ReadLine());
  8.  
  9.         // MATRIX INFO
  10.         var infoMatrix = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
  11.         var MatrixRows = infoMatrix[0];
  12.         var MatrixCols = infoMatrix[1];
  13.         var mainMatrix = new decimal[MatrixRows, MatrixCols];
  14.  
  15.         // FILL IN MATRIX
  16.         for (int rows = 0; rows < MatrixRows; rows++)
  17.         {
  18.             var readLine = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
  19.             for (int cols = 0; cols < MatrixCols; cols++)
  20.             {
  21.                 mainMatrix[rows, cols] = readLine[cols];
  22.             }
  23.         }
  24.         // BLUR INFO
  25.         var infoBlur = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
  26.         var blurRow = infoBlur[0];
  27.         var blurCol = infoBlur[1];
  28.  
  29.         var blurStartRows = blurRow - 1;
  30.         var blurEndRows = blurStartRows + 3;
  31.         if (blurStartRows < 0) blurStartRows = 0;
  32.         if (blurEndRows > MatrixRows) blurEndRows = MatrixRows;
  33.  
  34.         var blurStartCols = blurCol - 1;
  35.         var blurEndCols = blurStartCols + 3;
  36.         if (blurStartCols < 0) blurStartCols = 0;
  37.         if (blurEndCols > MatrixCols) blurEndCols = MatrixCols;
  38.  
  39.         //ADDING BLUR
  40.  
  41.         for (int rows = blurStartRows; rows < blurEndRows; rows++)
  42.         {
  43.             for (int cols = blurStartCols; cols < blurEndCols; cols++)
  44.             {
  45.                 mainMatrix[rows, cols] = mainMatrix[rows, cols] + blurAmount;
  46.             }
  47.         }
  48.        
  49.         //PRINT
  50.         for (int rows = 0; rows < MatrixRows; rows++)
  51.         {
  52.             for (int cols = 0; cols < MatrixCols; cols++)
  53.             {
  54.                 Console.Write(mainMatrix[rows, cols] + " ");
  55.             }
  56.             Console.WriteLine();
  57.         }
  58.     }
  59. }
Advertisement
Add Comment
Please, Sign In to add comment