PLEASE
package zh.codegym.task.task19.task1916;
import java.io.*;
import java.util.*;
/*
跟踪更改
*/
public class Solution {
public static List<LineItem> lines = new ArrayList<>();
public static void main(String[] args) throws IOException{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
BufferedReader br1=new BufferedReader(new FileReader(br.readLine()));
BufferedReader br2=new BufferedReader(new FileReader(br.readLine()));
ArrayList<String> a=new ArrayList<String>();
ArrayList<String> b=new ArrayList<String>();
ArrayList<String> c=new ArrayList<String>();
while (br1.ready()){
a.add(br1.readLine());
}
while (br2.ready()){
b.add(br2.readLine());
}
for(String linea:a){
for(String lineb:b){
if(linea.equals(lineb)){
c.add(linea);
}
}
}
for(String sameline:c){
a.remove(sameline);
b.remove(sameline);
}
br2.close();
br1.close();
br.close();
int counta=0;
int countb=0;
boolean flag=true;
for(String line:c){
lines.add(new LineItem(Type.SAME,"SAME "+line));
if(counta<a.size()&&flag==true){
lines.add(new LineItem(Type.REMOVED,"REMOVED "+a.get(counta)));
flag=false;
counta++;
}else {
lines.add(new LineItem(Type.ADDED,"ADDED "+b.get(countb)));
flag=true;
countb++;
}
}
}
public static enum Type {
ADDED, // 添加了新行
REMOVED, // 删除了行
SAME // 无更改
}
public static class LineItem {
public Type type;
public String line;
public LineItem(Type type, String line) {
this.type = type;
this.line = line;
}
}
}