Advertisement
SergeyPGUTI

Class AdjecencyMatrix

Apr 16th, 2016
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.66 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3.  
  4. //матрица смежности
  5. public class AdjacencyMatrix {
  6.     private int Matrix[][];
  7.     private int n;
  8.     private int m;
  9.     public AdjacencyMatrix(int n,int m)
  10.     {
  11.         Matrix=new int[n][m];
  12.         this.n=n;
  13.         this.m=m;
  14.     }
  15.     //считать матрицу с консоли
  16.     public void consoleRead()
  17.     {
  18.         Scanner sc=new Scanner(System.in);
  19.         for (int i=0;i<n;i++)
  20.             for (int j=0;j<m;j++)
  21.                 Matrix[i][j]=sc.nextInt();
  22.     }
  23.     //вернуть элемент матрицы
  24.     public int get(int i,int j)
  25.     {
  26.         return Matrix[i][j];
  27.     }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement