#그래프와 인접 행렬
## CODE <a class='btn btn-default' href='/codes/8389'>Link</a>
```
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int nodeCnt = input.nextInt();
System.out.println();
int lineCnt = input.nextInt();
DirectedGraph graph = new DirectedGraph(nodeCnt);
for (int i = 0; i < lineCnt; i++) {
int startNode = input.nextInt();
int endNode = input.nextInt();
graph.addEdge(startNode, endNode);
}
graph.printMatrix();
}
}
class DirectedGraph {
private int n; // 정점 수
private int[][] matrix; // 인접 행렬
public DirectedGraph(int n) {
this.n = n;
this.matrix = new int[n][n];
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
matrix[i][j] = 0;
}
}
}
public void addEdge(int start, int end) {
matrix[start][end] = 1;
}
public void printMatrix() {
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
System.out.print(matrix[i][j] + " ");
}
System.out.println();
}
}
}
```
## INPUT
```
4
4
0 1
0 2
2 0
3 2
```
## OUPUT
```
Exception in thread "main" java.util.NoSuchElementException
at java.util.Scanner.throwFor(Scanner.java:862)
at java.util.Scanner.next(Scanner.java:1485)
at java.util.Scanner.nextInt(Scanner.java:2117)
at java.util.Scanner.nextInt(Scanner.java:2076)
at Main.main(Main.java:8)
```
이클립스에서 돌리면 출력 결과가 잘 나오는데 여기서 돌리면 오류가 뜨네요 ㅠㅠ 방법이 없을까요..
sehongpark님의 답변
# 스캐너 생성 부분을 바꿔보세요
스캐너 생성 시 전달 인자를, 아래와 같이 바꿔보세요.
```
Scanner input = new Scanner(String.join(" ", args));
```
fud3725님의 답변
감사합니다!!! 잘 돌아가네요ㅎㅎ