Advertisement
Guest User

Untitled

a guest
Jan 18th, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.32 KB | None | 0 0
  1. package pkg311;
  2.  
  3. /**
  4. *
  5. * @author Acer
  6. */
  7. import java.io.Serializable;
  8. import java.util.Random;
  9.  
  10. public class Matrix implements Serializable{
  11.  
  12. private static double[][] arr;
  13. private int[] size;
  14. private static int m;
  15. private static int n;
  16.  
  17. Matrix(int m, int n) {
  18. Random rnd = new Random();
  19. arr = new double[m][n];
  20. for (int i = 0; i < m; i++)
  21. {
  22. for (int j = 0; j < n; j++)
  23. {
  24. arr[i][j]=rnd.nextDouble();
  25. }
  26. }
  27. }
  28.  
  29. public int[] getSize() {
  30. size = new int[2];
  31. size[0] = arr.length;
  32. size[1] = arr[0].length;
  33. return size;
  34. }
  35.  
  36.  
  37. public void setArr(double value, int i, int j) {
  38. arr[i][j] = value;
  39. }
  40.  
  41. public double getArr(int i, int j) {
  42. return arr[i][j];
  43. }
  44.  
  45. public static double[][] Func(double[][] arr, int m, int n) {
  46. double tmp = 0.0;
  47. for(int x =n-1 ; x > 0 ; x--){
  48. for(int j = 0 ; j < x ; j++){
  49. if( arr[0][j] > arr[0][j+1] ){
  50. for(int i = 0; i < m; i++) {
  51. tmp = arr[i][j];
  52. arr[i][j] = arr[i][j + 1];
  53. arr[i][j + 1] = tmp;
  54. }
  55. }
  56. }
  57. }
  58. return arr;
  59. }
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement