package 上機練習; public class A03class { public String showA(int rows, String ch) { for (int i = 0; i < rows; i++) { for (int j = 0; j <= i; j++) { System.out.print(ch); } System.out.println(); } return ch; } } package 上機練習; import java.util.Scanner; public class A03 { public static void main(String[] args) { // TODO Auto-generated method stub A03class A03 = new A03class(); Scanner in = new Scanner(System.in); System.out.println("請輸入行數:"); int rows = in.nextInt(); System.out.println("請輸入打印的圖案:"); String ch = in.next(); A03.showA(rows, ch); } }