首页 > 其他 > 详细

杨辉三角形

时间:2017-03-27 23:51:18      阅读:320      评论:0      收藏:0      [点我收藏+]

package yanghuisanjiao;

public class yanghuisanjiao {
 public static void main(String args[]){
 int i,j; 
  int a[][];
  a=new int[50][50];
  for(i=0;i<a.length;i++){
   a[i]=new int[i+1];
  for(j=0;j<=i;j++){
  if(i==0||j==0){
      a[i][j]=1;
  }
  else{
   a[i][j]=a[i-1][j-1]+a[i-1][j];
   }
  
  }
  System.out.print(a[i][j]+" ");
  }
  System.out.println();
  }
}

杨辉三角形

原文:http://www.cnblogs.com/cqy20152111128/p/6629501.html

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