写出3个算法,分别打印出正方形,菱形,空心长方形,example:
section:code
public class Rhomb {
public static void main(String[] args) {
/*正方形*/
int squareH=10;
int squareW=20;//一个星型的高度约等于2个星形的宽度
/*正方形算法实现*/
System.out.println("【*正方行*】:");
for(int e=0;e<10;e++) {
//打印空格
for(int f=0;f<5;f++) {
System.out.print(" ");
}
//打印星型
for(int g=0;g<squareW;g++) {
System.out.print("*");
}
System.out.println();//每打印一排,就换一行
}