java编程题

2022-04-18 社会 87阅读
import java.util.*;
import java.io.*;
class Main{
    public static void main(String[] args) throws Exception{
        String[] ts={"A.txt","B.txt","C.txt"};
        Scanner[] ss=new Scanner[ts.length];
        for(int i=0;i            ss[i] = new Scanner(new File(ts[i]));    
        }
        ArrayList list1=new ArrayList();
        while(ss[0].hasNext()){
            list1.add(ss[0].next());
        }
        ArrayList list2=new ArrayList();
        while(ss[1].hasNext()){
            String n=ss[1].next();
            if(list1.contains(n)){
                list2.add(n);
            }
        }
        while(ss[2].hasNext()){
            String n=ss[2].next();
            if(list2.contains(n)){
                list2.remove(n);
            }
        }
        for(int i=0;i            ss[i].close();
        }
        System.out.println(list2.size());
    }
}
声明:你问我答网所有作品(图文、音视频)均由用户自行上传分享,仅供网友学习交流。若您的权利被侵害,请联系fangmu6661024@163.com