package 孔得秀;
public class 杨辉三角 {
public static void main(String args[])
{
int i,j,x=6;//定义三角层数
int a[][] = new int[x][x];//定义数组
for( i=0;i<x;i++)//对数组进行赋值
{
for(j=0;j<=i;j++)//每一层的个数都是小于等于层数的,m代表层数,n代表着第几个数
{
if(j==0||i==j)//每一层的开头都是1,m==n的时候也是1;
{
a[i][j]=1;
}
else
{
a[i][j]=a[i-1][j-1]+a[i-1][j];//递推的方法
}
}
}
for(i=0;i<x;i++)//输出数组
{
for(j=x-i;j<=x;j++)//打印数组,每层循环几次就几个
{
System.out.print(a[i][x-j]+" ");
}
System.out.println();//每层换行
}
}
}
结果:
1 2 1 1 3 3 1 1 4 6 4 1 1 5 10 10 5 1
SDK接入(2)之Android Google Play内支付(in-app Billing)接入
Google In-App Billing 实现(内含Unity 实现经验)
unity3d如何快速接入渠道SDK之Unity篇
[Unity3D]Unity+Android交互教程——让手机"动"起来
mysql avg()函数,获取字段的平均值
mysql tan() 函数
mysql pi() 获取pi
mysql mod() 获取余数
mysql sqrt() 函数