-------------------------------------
AC代码:
1 import java.util.Scanner; 2 3 public class Main { 4 5 public static void main(String[] args) { 6 7 Scanner sc=new Scanner(System.in); 8 9 int times=sc.nextInt(); 10 11 while(times-->0){ 12 int n=sc.nextInt(); 13 for(int i=n;i>0;i--){ 14 System.out.println(repeate("*",i)); 15 } 16 } 17 } 18 19 public static String repeate(String s,int times){ 20 StringBuilder sb=new StringBuilder(s.length()*times); 21 while(times-->0) sb.append(s); 22 return sb.toString(); 23 } 24 25 }