I have an input of
-157,118
-170,12
-74,139
-144,42
-155,196
122,-88
-187,-143
156,-18
-67,126
44,-102
....
像这样。我必须检查文件中的每个数字(我有更多这样的输入)并且必须找到属于 (+ve,+ve) 的对。请任何人帮助我。我能够从文件.我已经这样做了..
public class EulerGift {
public static void main(String[] args) {
// List<String> coordinateList=new ArrayList<String>();
File file = new File("D:/coordinate.txt");
try {
Scanner sc = new Scanner(file);
while (sc.hasNext()) {
String value = sc.next();
String[] tokens = value.split(",");
for (int i = 0; i < tokens.length; i++) {
System.out.println("("+Integer.parseInt(tokens[i])+")");
// System.out.println(Integer.parseInt(tokens[i]));
}
}
} catch (FileNotFoundException e) {
System.err.format("File Not Found");
}
}
}