问题陈述:https ://pastebin.com/LzvZecyQ我有 2 个输入文件来测试这个算法。第一: https ://pastebin.com/BtsiZqqn我得到了这个输出:案例#1:5(这个不错)二: https ://pastebin.com/fTbdbpnW我得到了这个输出:案例#1:1案例#2:1案例#3:9案例#4:4案例#5:101案例#6:3.125问题:所有情况都可以,但第 6 次是错误的。我正在使用这段代码:public class DemoApplication { private static final Logger LOGGER = Logger.getLogger("com.example.demo.DemoApplication"); private static final String TEMPLATE = "Case #{0}: {1}\r\n"; private static final String PLANET_START = "Galactica"; private static final String PLANET_END = "New Earth"; public static void main(String args[]) { String inputFilePath = "testInput.txt"; String outputFilePath = "output.txt"; try (BufferedReader reader = Files.newBufferedReader(Paths.get(inputFilePath))) { //Create the reader with the file path of testInput.txt try (BufferedWriter writer = Files.newBufferedWriter(Paths.get(outputFilePath))) { //Create the writer with the file path we want the output String line = reader.readLine();//skip first row int i = 0;//Counter of lines Map<String, String[]> planets = null; int caseNumber = 0;我做错了什么?如果可能的话,我更喜欢解释为什么这不适用于案例 6,而不是给我解决方案。这是因为我正在尝试学习算法。这个问题是 tuenti 挑战的第二个问题(https://contest.tuenti.net/Contest)如果有人有兴趣我想你仍然可以参加。提前致谢。
添加回答
举报
0/150
提交
取消