Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class mani2darray {
- public static int [][] cmultiply (int A[][], int c){
- for (int i =0; i <A.length; i++){
- for (int j =0; j <A[0].length; j++){
- A[i][j] = c* A[i][j];
- }
- }
- return A;
- }
- public static int [][] multiply (int A[][], int B[][]){
- int answer [] [] = new int [A.length][A.length];
- for (int i =0; i < A.length; i ++){
- for (int j=0; j <A.length; j++){
- for (int k = 0; k < A[0].length; k++)
- answer[i][j] += A[i][k] * B[k][j];
- }
- }
- return answer;
- }
- public static int [] [] flipvertically (int A[][]){
- int answer [] [] = new int [A.length] [A[0].length];
- int counter =0;
- for (int i = A.length -1; i >= 0; i--){
- for(int j=0; j<A[0].length; j++){
- answer[counter][j] = A[i][j];
- }
- counter++;
- }
- return answer;
- }
- public static int [] [] fliphorizontally (int A[][]){
- int answer [] [] = new int [A.length] [A[0].length];
- for (int i =0; i < A.length; i ++){
- int counter =0;
- for (int j= A[0].length -1; j >= 0; j--){
- answer[i][counter] = A[i][j];
- counter ++;
- }
- }
- return answer;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement