MatriceLib - class MatriceLib cfw_ / METHOD display:...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
class MatriceLib { // METHOD display: Displays the content of a matrix // GIVENS: mat, a matrix of integers // RESULT: None // ASSUMPTIONS: the matrix is not empty public static void display (int[][] mat) { // DECLARATION OF VARIABLES / DATA DICTIONNARY int noRows, noCols; // INTERMEDIATES: size of mat int r, c; // INTERMEDIATES: Index for traversing the matrix // BODY OF THE ALGORITHM noRows = mat.length; noCols = mat[0].length; r = 0; while (r < noRows) { c = 0; while (c < noCols) { System.out.print(mat[r][c] + " "); c = c + 1; } System.out.println(); // go to the next row r = r + 1; } // RETURN RESULT: NONE } // METHOD compare: test the equality of two matrices // GIVENS: mat1 and mat2: two matrices of integers // RESULT: true is their content is equal // ASSUMPTIONS: the matrices are not empty public static boolean compare (int[][] mat1, int[][] mat2) { // DECLARATION OF VARIABLES / DATA DICTIONNARY int noRows1, noCols1; // INTERMEDIATES: size of mat1 int r, c; // INTERMEDIATES: Index for traversing the matrices
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 01/06/2011 for the course ITI 1120 taught by Professor Inkpen during the Fall '07 term at University of Ottawa.

Page1 / 2

MatriceLib - class MatriceLib cfw_ / METHOD display:...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online