package chapter7;
public class T21 {
public static void main(String[] args) {
int boll = 5;
int slot = 8;
int[] b = new int[boll];
for(int i=0;i<boll;i++){
b[i]=1;
for(int j=0;j<slot;j++){
int random = r();
b[i]+=random;
if(random==0)
System.out.print("L");
else
System.out.print("R");
}
System.out.println();
}
System.out.println();
for(int e:b){
System.out.print(e+" ");
}
System.out.println();
for(int i=0;i<boll;i++){
for(int j=0;j<b[i];j++)
System.out.print(" ");
System.out.println("0");
}
}
public static int r(){
return (int)(Math.random()*2);
}
}
java语言程序设计第十版(Introduce to java 10th) 课后习题 chapter7-21
最新推荐文章于 2020-07-09 13:31:17 发布