import java.util.ArrayList;
import java.util.List;
import java.util.Random;
public class lianxi {
public static void main(String[] args) {
List<String> blacks=new ArrayList<>();
List<String> whites=new ArrayList<>();
for (int i = 0; i < 29; i++) {
blacks.add(""+i);
}
for (int i = 0; i < 21; i++) {
whites.add(""+i);
}
Random random = new Random();
for (int i = 0; i < 48; i++) {
int math = random.nextInt(3);
System.out.println(math);
if (math == 0) {
//魔术师每次从袋中随意摸出两个球放外面,如果摸出的两个球同色,就另外再拿一个黑球放入袋中,如果摸出的两个球异色,就把其中那个白球放回袋中,这样操作了48次,袋中还剩下几个球?各是什么颜色的
blacks.add(""+blacks.size());
}
if (math==1){
blacks.remove(blacks.size()-1);
}
if (math==2){
blacks.add(""+blacks.size());
}
}
System.out.println("黑色球数量"+blacks.size());
System.out.println("白色球数量"+whites.size());
}
}