Advertisement
Guest User

Untitled

a guest
May 21st, 2019
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. import java.util. *;
  2. public class firstfirst {
  3.  
  4. public static int[][] secondmatrix(int[][] A, int[][] B, int n){
  5. for (int j = 0; j < n; j++){
  6. for (int i = 1; i < n-1; i++){
  7. if ((A[i-1][j]<A[i][j]) & (A[i][j]>A[i+1][j]))
  8. B[j][i] = 1;
  9. else
  10. B[j][i] = 0;
  11. }
  12. }
  13. return B;
  14. }
  15.  
  16. public static int[][] show(int[][] B, int n){
  17. for (int i = 0; i < n; i++){
  18. for (int j = 0; j < n; j++){
  19. System.out.print(B[i][j] + " ");
  20. }
  21. System.out.print("\n");
  22. }
  23. return B;
  24. }
  25.  
  26. public static void main (String args[]) {
  27. Scanner in = new Scanner(System.in);
  28. System.out.print("Select a dimensional of the matrix \n");
  29. int n = in.nextInt();
  30. int [] [] A = new int [n][n];
  31. int [] [] B = new int [n][n];
  32. for (int j = 0; j < n; j++){
  33. for (int i = 0; i < n; i++){
  34. System.out.print("Input a number in the matrix \n");
  35. A[i][j] = in.nextInt();
  36. }
  37. }
  38. secondmatrix(A, B, n);
  39. show(B, n);
  40. }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement