AcWing 1204. 错误票据
原题链接
简单
作者:
Augus002
,
2024-04-03 22:04:51
,
所有人可见
,
阅读 3
Java 代码
import java.util.*;
public class Main {
private static int[] st = new int[100010];
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int n = scanner.nextInt();
scanner.nextLine();
int min = 100010, max = -1;
for(int i = 1; i <= n; i++){
String[] chars = scanner.nextLine().split(" ");
for(int j = 0; j < chars.length; j++)
{
Integer integer = Integer.valueOf(chars[j]);
st[integer]++;
if(integer > max) max = integer;
if(integer < min) min = integer;
}
}
for(int i = min + 1; i < max; i++){
if(st[i] == 0) System.out.print(i + " ");
}
for(int i = min; i <= max; i++){
if(st[i] == 2) System.out.print(i);
}
scanner.close();
}
}