Ivakis

BlurFilter

Sep 19th, 2017
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.31 KB | None | 0 0
  1. import java.util.Arrays;
  2. import java.util.Scanner;
  3.  
  4. public class p13_BlurFilter {
  5. public static void main(String[] args) {
  6. Scanner scanner = new Scanner(System.in);
  7.  
  8. int blurWeight = Integer.parseInt(scanner.nextLine());
  9. int[] rowsCols = Arrays.stream(scanner.nextLine().split(" ")).mapToInt(Integer::parseInt).toArray();
  10. long[][] matrix = new long[rowsCols[0]][rowsCols[1]];
  11.  
  12. for (int i = 0; i < rowsCols[0]; i++) {
  13.  
  14. int[] input = Arrays.stream(scanner.nextLine().split(" ")).mapToInt(Integer::parseInt).toArray();
  15.  
  16. for (int j = 0; j < rowsCols[1]; j++) {
  17. matrix[i][j] = input[j];
  18. }
  19. }
  20.  
  21. int[] target = Arrays.stream(scanner.nextLine().split(" ")).mapToInt(Integer::parseInt).toArray();
  22.  
  23. for (int i = target[0] - 1; i <= target[0] + 1; i++) {
  24. for (int j = target[1] - 1; j <= target[1] + 1; j++) {
  25. try {
  26. matrix[i][j] += blurWeight;
  27. } catch (Exception ex) {
  28. continue;
  29. }
  30. }
  31. }
  32.  
  33. for (long[] row : matrix) {
  34. for (long j : row) {
  35. System.out.print(j + " ");
  36. }
  37.  
  38. System.out.println("");
  39. }
  40.  
  41. }
  42. }
Add Comment
Please, Sign In to add comment