Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package pkg311;
- /**
- *
- * @author Acer
- */
- import java.io.Serializable;
- import java.util.Random;
- public class Matrix implements Serializable{
- private static double[][] arr;
- private int[] size;
- private static int m;
- private static int n;
- Matrix(int m, int n) {
- Random rnd = new Random();
- arr = new double[m][n];
- for (int i = 0; i < m; i++)
- {
- for (int j = 0; j < n; j++)
- {
- arr[i][j]=rnd.nextDouble();
- }
- }
- }
- public int[] getSize() {
- size = new int[2];
- size[0] = arr.length;
- size[1] = arr[0].length;
- return size;
- }
- public void setArr(double value, int i, int j) {
- arr[i][j] = value;
- }
- public double getArr(int i, int j) {
- return arr[i][j];
- }
- public static double[][] Func(double[][] arr, int m, int n) {
- double tmp = 0.0;
- for(int x =n-1 ; x > 0 ; x--){
- for(int j = 0 ; j < x ; j++){
- if( arr[0][j] > arr[0][j+1] ){
- for(int i = 0; i < m; i++) {
- tmp = arr[i][j];
- arr[i][j] = arr[i][j + 1];
- arr[i][j + 1] = tmp;
- }
- }
- }
- }
- return arr;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement