public class dayinjuxing{
public static void main(String[] args){
for(int i = 1;i <= 4;i++){
for(int j = 1;j <= 5;j++){
System.out.print("*");
}
System.out.println();
}
}
}
int length = 5;
int height = 4;
for(int i = 0;i < height;i++){
for(int j = 0;j < length;j++){
if(i == 0){
System.out.print("*");
}
else if(i == height-1){
System.out.print("*");
}
else if(j == 0 || j == length-1){
System.out.print("*");
}
else{
System.out.print(" ");
}
}
System.out.println();
}
}
}
多重循环,打印矩形(实空心)
最新推荐文章于 2024-08-19 16:01:20 发布