Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util. *;
- public class firstfirst {
- public static int[][] secondmatrix(int[][] A, int[][] B, int n){
- for (int j = 0; j < n; j++){
- for (int i = 1; i < n-1; i++){
- if ((A[i-1][j]<A[i][j]) & (A[i][j]>A[i+1][j]))
- B[j][i] = 1;
- else
- B[j][i] = 0;
- }
- }
- return B;
- }
- public static int[][] show(int[][] B, int n){
- for (int i = 0; i < n; i++){
- for (int j = 0; j < n; j++){
- System.out.print(B[i][j] + " ");
- }
- System.out.print("\n");
- }
- return B;
- }
- public static void main (String args[]) {
- Scanner in = new Scanner(System.in);
- System.out.print("Select a dimensional of the matrix \n");
- int n = in.nextInt();
- int [] [] A = new int [n][n];
- int [] [] B = new int [n][n];
- for (int j = 0; j < n; j++){
- for (int i = 0; i < n; i++){
- System.out.print("Input a number in the matrix \n");
- A[i][j] = in.nextInt();
- }
- }
- secondmatrix(A, B, n);
- show(B, n);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement