直接上代码,在主函数中直接打印 public class Triangle { public static void main(String[] args) { // 输入循环行数 Scanner sc = new Scanner(System.in);