當前位置:編程學習大全網 - 網站源碼 - 用java定義壹個方法printZF(int height, int width)?

用java定義壹個方法printZF(int height, int width)?

長我給了常量7

public static void main(String[] args) {

int height,width1,width2,width3;

height = 7;

width1 = 5;

width2 = 4;

width3 = 6;

test014_打印正方形和矩形 t= new test014_打印正方形和矩形();

//正方形

t.printZF(width1,width1);

t.printZF(width2,width2);

t.printZF(width3,width3);

System.out.println("---------------");

//長方形

t.printZF(height,width1);

t.printZF(height,width2);

t.printZF(height,width3);

}

public void printZF(int height, int width){

String str = "";

for (int i = 0;i<width;i++){

for (int j = 0;j<height;j++){

str+="* ";

}

str += "\n";

}

System.out.println(str);

}

  • 上一篇:ssp廣告是什麽意思
  • 下一篇:柚子幣今日行情走勢價格是多少
  • copyright 2024編程學習大全網