Created
December 10, 2012 07:04
-
-
Save hamadu/4248972 to your computer and use it in GitHub Desktop.
InputChecker of problemA in WUPC2nd.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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