62,614
社区成员
发帖
与我相关
我的任务
分享
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
public class Test3 {
public static void main(String[] args) {
BufferedReader br = null;
try {
br = new BufferedReader(new FileReader("aa.txt"));
long n = Long.MIN_VALUE;
for(String line = null; (line = br.readLine()) != null; ) {
String[] str = line.split("\\s+");
long a = Long.parseLong(str[0]);
long b = Long.parseLong(str[1]);
if(n + 1 != a) {
if(n != Long.MIN_VALUE) {
System.out.println(" " + n);
}
System.out.print(a);
}
n = b;
}
System.out.println(" " + n);
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
br.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}