首页 > 编程语言 > 详细

JAVA编程 - 输出三角形

时间:2015-05-08 21:40:12      阅读:326      评论:0      收藏:0      [点我收藏+]

public static void main(String[] args) {
  System.out.println("输入三角形的行数");
  Scanner scanner = new Scanner(System.in);
  int n = scanner.nextInt();
  for (int i = 0; i < n; i++) {
    for (int x = i + 1; x < n; x++) {
      System.out.print(" ");
  }
   for (int y = 0; y < (i + 1) * 2 - 1; y++) {
      System.out.print("*");
  }
      System.out.print(‘\n‘);
  }
}

JAVA编程 - 输出三角形

原文:http://www.cnblogs.com/AllenIverson/p/4488757.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!