七、错误票据
package com.markerhub;import java.util.Scanner;
import java.util.ArrayList;
import java.util.Collections;public class TEST { public static void main(String[] args) {Scanner sc = new Scanner(System.in);int N = sc.nextInt();sc.nextLine(); ArrayList<Integer> list = new ArrayList<Integer>(); for(int i = 0; i < N; i++) {String line = sc.nextLine();String[] split = line.split(" ");for(int j = 0; j < split.length; j++) {list.add(Integer.parseInt(split[j])); }}Collections.sort(list);int brokenNumber = 0, repeatedNumber = 0; for(int i = 1 ; i < list.size(); i++) {if(list.get(i) - list.get(i-1) == 2) {brokenNumber = list.get(i) - 1;}if(list.get(i).equals(list.get(i-1))) {repeatedNumber = list.get(i);}}System.out.println(brokenNumber + " " + repeatedNumber);}}