Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- import java.io.*;
- public class Text_Read {
- public static int [][] adjMatrix;
- /**
- * @param args the command line arguments
- */
- public static void main(String[] args) {
- try{
- Scanner sc=new Scanner(new File("E:\\aa.txt"));
- String [] spaceSplit;
- String temp1=sc.nextLine();
- Integer v=Integer.parseInt(temp1);
- String temp2=sc.nextLine();
- Integer e=Integer.parseInt(temp2);
- adjMatrix=new int[v][v];
- while(sc.hasNext())
- {
- String line=sc.nextLine();
- spaceSplit=line.split(" ");
- String tempo1=spaceSplit[0];
- String tempo2=spaceSplit[1];
- int x=Integer.parseInt(tempo1);
- int y=Integer.parseInt(tempo2);
- adjMatrix[x][y]=1;
- }
- for(int i=0;i<v;i++) {
- for(int j=0;j<v;j++) {
- System.out.print(adjMatrix[i][j]+",");
- }
- System.out.println();
- }
- }
- catch(Exception e){
- //System.out.println(e);
- e.printStackTrace();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement