-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQueens.java
More file actions
32 lines (26 loc) · 1.02 KB
/
Queens.java
File metadata and controls
32 lines (26 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package queeens;
import java.io.File;
import java.io.IOException;
import java.util.Scanner;
public class Queens {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in); //scanner for user input
System.out.println("Please enter the file name: ");
String fileName = scanner.nextLine();
try
{
Scanner read = new Scanner(new File(fileName)); //scanner for file
int n = read.nextInt(); //read number of rows
int m = read.nextInt(); //read number of columns
QueensProblem queens = new QueensProblem(n, m);
long startTime = System.currentTimeMillis();
queens.solve();
long endTime = System.currentTimeMillis();
System.out.println("Duration: " + (endTime - startTime) + " milliseconds");
}
catch (IOException e) //catch IO exception from the file input
{
System.out.println(e);
}
}
}