Skip to content

Instantly share code, notes, and snippets.

@hamadu
Created December 10, 2012 07:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hamadu/4248972 to your computer and use it in GitHub Desktop.
Save hamadu/4248972 to your computer and use it in GitHub Desktop.
InputChecker of problemA in WUPC2nd.
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.InputStreamReader;
public class InputCheckerA {
public static void main(String[] args) throws Exception {
File inputDir = new File("/path/to/the/input/files/directory");
for (File file : inputDir.listFiles()) {
BufferedReader reader = new BufferedReader(new FileReader(file));
if (!check(reader)) {
System.err.println("err:" + file.getName());
} else {
System.err.println("ok");
}
reader.close();
}
}
private static boolean check(BufferedReader reader) {
try {
String line = reader.readLine();
String[] data = line.split(" ");
if (data.length != 2) {
return false;
}
int N = Integer.valueOf(data[0]);
int M = Integer.valueOf(data[1]);
if (1 <= N && N <= 100) {
if (1 <= M && M <= 100) {
return true;
}
}
} catch (Exception e) {
return false;
}
return false;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment