1 package com.llh.demo;
 2 
 3 /**
 4  * 杨辉三角
 5  * 
 6  * @author llh
 7  *
 8  */
 9 public class Test {
10     /*
11      * 杨辉三角
12      */
13     public static void main(String[] args) {
14         int[] a = new int[11];
15         int num = 1;
16         //
17         for (int i = 1; i <= 10; i++) {
18             for (int j = 1; j <= i; j++) {
19                 int c = a[j];
20                 a[j] = num + c;
21                 num = c;
22                 System.out.print(a[j] + " ");
23             }
24             System.out.println();
25         }
26     }
27 
28 }

 java语言编写杨辉三角

相关文章:

  • 2021-10-26
  • 2021-09-07
  • 2021-11-16
  • 2021-11-05
  • 2021-07-18
  • 2022-12-23
  • 2022-12-23
  • 2021-12-06
猜你喜欢
  • 2021-05-08
  • 2022-01-16
  • 2021-08-31
  • 2022-12-23
  • 2021-05-21
  • 2021-12-26
  • 2021-12-22
相关资源
相似解决方案