这是我目前的项目代码。我有10或更高的数字,它读取每个数字而不是整数。有帮助吗? 我正在使用的数字:
1 3
1 1
-1 -5
5 3
45 45
1001001100 1001001100
$("input").mouseup(function () {
$(this).blur(); // This has no apparent affect.
$("#" + this.htmlFor).blur(); // Or this.
});
答案 0 :(得分:1)
你可以做的是用空格分割每一行,然后将每个元素解析为整个整数。类似的东西:
String[] ints = reader.nextLine().split(' ');
double first = Double.parseDouble(ints[0]);
double second = Double.parseDouble(ints[1]);
基本上做的是获取下一行,创建一个数组,其中每个元素被空格分割,然后尝试将空格前后的字符串作为单独的双精度处理。
答案 1 :(得分:1)
import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Scanner;
public class comparison_rylan_howard {
public static void main(String[] args) throws IOException {
Scanner reader = new Scanner(new
File("H:\\NetBeansProjects\\Unit1\\comparison.txt"));
try (PrintWriter writer = new PrintWriter("Results.txt")) {
while (reader.hasNext()) {
double first = reader.nextDouble();
double second = reader.nextDouble();
writer.println(first+","+second );
if (first <= -1 || second <= -1) {
writer.println("Error");
writer.println("");
}
else if (first > second) {
writer.println(">");
writer.println("");
}
else if (first < second) {
writer.println("<");
writer.println("");
} else {
writer.println("=");
writer.println("");
}
}
}
}
}
输出:
1.0,3.0
<
1.0,1.0
=
-1.0,-5.0
Error
5.0,3.0
>
45.0,45.0
=
1.0010011E9,1.0010011E9
=