<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">public class MatrixOps {
  
  /* =Return a nr-by-nc 2-d int array of random values in [lo..hi] */
  public static int[][] randMatrix(int nr, int nc, int lo, int hi) {
    int[][] m= new int[nr][nc];
    for (int r=0; r&lt;nr; r++)
      for (int c=0; c&lt;nc; c++)
        m[r][c]= (int) Math.floor(Math.random()*(hi-lo+1)+lo);
    return m;
  }
    
  /* Print 2-d array m */
  public static void print(int[][] m) {
    for (int r=0; r&lt;m.length; r++){
      for (int c=0; c&lt;m[r].length; c++)
        System.out.print(m[r][c]+ "\t");
      System.out.println();
    }
  }

  /* Reverse the order of the rows of 2-d array m */
  public static void flipUD(int[][] m) {
    int[] temp;
    for (int t=0, b=m.length-1; t&lt;b; t++, b--) {
      temp= m[t];
      m[t]= m[b];
      m[b]= temp;
    }
  }

  /* Reverse the order of the columns of a rectangular 2-d array m */
  public static void flipLR(int[][] m) {
    int temp;
    for (int L=0, R=m[0].length-1; L&lt;R; L++, R--) {
      for (int r=0; r&lt;m.length; r++) {
        temp= m[r][L];
        m[r][L]= m[r][R];
        m[r][R]= temp;
      }
    }
  }


}

</pre></body></html>