|
| 1 | +// package supports; |
| 2 | + |
| 3 | +publicclassMethods { |
| 4 | + |
| 5 | +publicstaticvoidprintArray(int[]arr) { |
| 6 | +System.out.print("array: "); |
| 7 | +for(inti :arr) |
| 8 | +System.out.print(i +" "); |
| 9 | +System.out.println(); |
| 10 | +} |
| 11 | + |
| 12 | +publicstaticvoidprintArray(char[]arr) { |
| 13 | +System.out.print("array:\t"); |
| 14 | +for(chari :arr) |
| 15 | +System.out.print(i +""); |
| 16 | +System.out.println(); |
| 17 | +} |
| 18 | +publicstaticvoidprintArray(String[]arr) { |
| 19 | +System.out.print("array: "); |
| 20 | +for(Stringi :arr) |
| 21 | +System.out.print(i +" "); |
| 22 | +System.out.println(); |
| 23 | +} |
| 24 | +publicstaticvoidprintArray(boolean[]arr) { |
| 25 | +System.out.print("array: "); |
| 26 | +for(booleani :arr) |
| 27 | +System.out.print((i?1:0) +" "); |
| 28 | +System.out.println(); |
| 29 | +} |
| 30 | + |
| 31 | +publicstaticvoidprintMatrix(char[][]matrix) { |
| 32 | +intN =matrix[0].length; |
| 33 | +System.out.print("matrix:\n"); |
| 34 | +for(char[]row :matrix) { |
| 35 | +for(intj=0;j<N;j++) |
| 36 | +System.out.print(row[j] +" "); |
| 37 | +System.out.println(); |
| 38 | +} |
| 39 | +} |
| 40 | +publicstaticvoidprintMatrix(int[][]matrix) { |
| 41 | +intN =matrix[0].length; |
| 42 | +System.out.print("matrix:\n"); |
| 43 | +for(int[]row :matrix) { |
| 44 | +for(intj=0;j<N;j++) |
| 45 | +System.out.print(row[j] +" "); |
| 46 | +System.out.println(); |
| 47 | +} |
| 48 | +} |
| 49 | +publicstaticvoidprintMatrix(long[][]matrix) { |
| 50 | +intN =matrix[0].length; |
| 51 | +System.out.print("matrix:\n"); |
| 52 | +for(long[]row :matrix) { |
| 53 | +for(intj=0;j<N;j++) |
| 54 | +System.out.print(row[j] +" "); |
| 55 | +System.out.println(); |
| 56 | +} |
| 57 | +} |
| 58 | +publicbooleanisSymmetric(int[][]matrix) { |
| 59 | +introws =matrix.length; |
| 60 | +if(rows<1)returntrue; |
| 61 | +intcols =matrix[0].length; |
| 62 | +if(rows!=cols)returnfalse; |
| 63 | +for(inti=0;i<rows;i++) { |
| 64 | +for(intj=i+1;j<cols;j++) { |
| 65 | +if(matrix[i][j]!=matrix[j][i])returnfalse; |
| 66 | +} |
| 67 | +} |
| 68 | +returntrue; |
| 69 | +} |
| 70 | +} |