Advertisement
Guest User

Untitled

a guest
Apr 16th, 2014
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. public class mani2darray {
  2. public static int [][] cmultiply (int A[][], int c){
  3. for (int i =0; i <A.length; i++){
  4. for (int j =0; j <A[0].length; j++){
  5. A[i][j] = c* A[i][j];
  6. }
  7. }
  8. return A;
  9. }
  10.  
  11. public static int [][] multiply (int A[][], int B[][]){
  12. int answer [] [] = new int [A.length][A.length];
  13. for (int i =0; i < A.length; i ++){
  14. for (int j=0; j <A.length; j++){
  15. for (int k = 0; k < A[0].length; k++)
  16. answer[i][j] += A[i][k] * B[k][j];
  17. }
  18. }
  19. return answer;
  20. }
  21.  
  22.  
  23. public static int [] [] flipvertically (int A[][]){
  24. int answer [] [] = new int [A.length] [A[0].length];
  25. int counter =0;
  26. for (int i = A.length -1; i >= 0; i--){
  27. for(int j=0; j<A[0].length; j++){
  28. answer[counter][j] = A[i][j];
  29. }
  30. counter++;
  31. }
  32. return answer;
  33. }
  34.  
  35. public static int [] [] fliphorizontally (int A[][]){
  36. int answer [] [] = new int [A.length] [A[0].length];
  37. for (int i =0; i < A.length; i ++){
  38. int counter =0;
  39. for (int j= A[0].length -1; j >= 0; j--){
  40. answer[i][counter] = A[i][j];
  41. counter ++;
  42. }
  43. }
  44. return answer;
  45. }
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement