华为od机试 告警抑制

package main;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

/*
 * 告警抑制
 */
public class test5 {
    

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        while(in.hasNext()){
            //读入数据
            int length = in.nextInt();
            String[][] c = new String[length][2];
            for (int i = 0; i < c.length; i++) {
                c[i][0] = in.next();
                c[i][1] = in.next();
            }
            String[] s = {"A","B","C","D","E"};
            List ans = new ArrayList<>();
            for (int i = 0; i < s.length; i++) {
                ans.add(s[i]);
            }
            
            List del = new ArrayList<>();
            for(int i = 0 ; i < c.length ; i ++){
                if(ans.contains(c[i][0])){
                    if(ans.contains(c[i][1])){
                        del.add(c[i][1]);
                    }
                }
            }
            for(int i = 0 ; i < del.size() ; i ++){
                ans.remove(del.get(i));
            }
            System.out.println(ans.toString());
        }
    }
}

华为od机试 告警抑制_第1张图片

 

你可能感兴趣的:(java)