Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Enter your code herepublic class Main {
- public static void main(String[] args) {
- Matrix obj;
- obj.eye(5);
- obj.print();
- }
- }
- ________________________________
- /**
- * Created by yevvy on 14/10/2016.
- */
- public class Matrix {
- private int row;
- private int col;
- private double[][] matrix;
- public Matrix(int row, int col){
- matrix = new double[row][col];
- }
- public void eye(int size){
- matrix = new double[size][size];
- row = size;
- col = size;
- for(int i=0; i<size; i++)
- matrix[i][i]=1;
- }
- public void print(){
- for(int i=0; i<row; i++) {
- for (int j = 0; i < col; i++)
- System.out.print(matrix[i][j]);
- System.out.println();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement