zoukankan      html  css  js  c++  java
  • 【宋红康程序思想学习日记3】杨辉三角

    class Shuzu3
    {
    public static void main(String[] args)
    {
        int[][] yanghui=new int[10][];
      //初始化二维数组
      for(int i=0;i<yanghui.length;i++){
        yanghui[i]=new int[i+1];
    }
      for(int i=0;i<yanghui.length;i++){
        for(int j=0;j<yanghui[i].length;j++){
          yanghui[i][0]=yanghui[i][i]=1;
          if(i>=2&&j>0&&j<i){
            yanghui[i][j]=yanghui[i-1][j-1]+yanghui[i-1][j];
        }

          System.out.print(yanghui[i][j]+"\t");
      }
      System.out.println();
      }
    }
    }
    //从这个程序可以看出本人在写程序思考不够缜密,下次写程序要先写好思路再尽力写好 每一步,从大到小一步一步完善检查无误后再进行编译运行。不要以编译来检查错误所在

  • 相关阅读:
    Permutation Sequence
    Anagrams
    Unique Binary Search Trees II
    Interleaving String
    Longest Substring Without Repeating Characters
    Sqrt(x)
    Maximum Product Subarray
    Jump Game II
    Container With Most Water
    C结构体的初始化和赋值
  • 原文地址:https://www.cnblogs.com/noaman/p/4926567.html
Copyright © 2011-2022 走看看