3个回答
展开全部
public class YangHui {
public static void main(String args[]) {
final int ROW = 10;
int a[][] = new int[ROW + 1][];
for (int i = 0; i <= ROW; i++) {
a[i] = new int[i + 1]; // 指定每行的列数
}
yanghui(a, ROW);
}
static void yanghui(int a[][], int ROW) {
for (int i = 0; i <= ROW; i++)
for (int j = 0; j <= a[i].length - 1; j++) {
if (i == 0 || j == 0 || j == a[i].length - 1)
a[i][j] = 1;
else
a[i][j] = a[i - 1][j - 1] + a[i - 1][j];
}
for (int i = 0; i <= ROW; i++) {
for (int j = 0; j <= a[i].length - 1; j++)
System.out.print(a[i][j] + "\t");
System.out.println();
}
}
}
public static void main(String args[]) {
final int ROW = 10;
int a[][] = new int[ROW + 1][];
for (int i = 0; i <= ROW; i++) {
a[i] = new int[i + 1]; // 指定每行的列数
}
yanghui(a, ROW);
}
static void yanghui(int a[][], int ROW) {
for (int i = 0; i <= ROW; i++)
for (int j = 0; j <= a[i].length - 1; j++) {
if (i == 0 || j == 0 || j == a[i].length - 1)
a[i][j] = 1;
else
a[i][j] = a[i - 1][j - 1] + a[i - 1][j];
}
for (int i = 0; i <= ROW; i++) {
for (int j = 0; j <= a[i].length - 1; j++)
System.out.print(a[i][j] + "\t");
System.out.println();
}
}
}
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
public
class
YangHui
{
public
static
void
main(String
args[])
{
final
int
ROW
=
10;
int
a[][]
=
new
int[ROW
+
1][];
for
(int
i
=
0;
i
<=
ROW;
i++)
{
a[i]
=
new
int[i
+
1];
//
指定每行的列数
}
yanghui(a,
ROW);
}
static
void
yanghui(int
a[][],
int
ROW)
{
for
(int
i
=
0;
i
<=
ROW;
i++)
for
(int
j
=
0;
j
<=
a[i].length
-
1;
j++)
{
if
(i
==
0
||
j
==
0
||
j
==
a[i].length
-
1)
a[i][j]
=
1;
else
a[i][j]
=
a[i
-
1][j
-
1]
+
a[i
-
1][j];
}
for
(int
i
=
0;
i
<=
ROW;
i++)
{
for
(int
j
=
0;
j
<=
a[i].length
-
1;
j++)
System.out.print(a[i][j]
+
"\t");
System.out.println();
}
}
}
class
YangHui
{
public
static
void
main(String
args[])
{
final
int
ROW
=
10;
int
a[][]
=
new
int[ROW
+
1][];
for
(int
i
=
0;
i
<=
ROW;
i++)
{
a[i]
=
new
int[i
+
1];
//
指定每行的列数
}
yanghui(a,
ROW);
}
static
void
yanghui(int
a[][],
int
ROW)
{
for
(int
i
=
0;
i
<=
ROW;
i++)
for
(int
j
=
0;
j
<=
a[i].length
-
1;
j++)
{
if
(i
==
0
||
j
==
0
||
j
==
a[i].length
-
1)
a[i][j]
=
1;
else
a[i][j]
=
a[i
-
1][j
-
1]
+
a[i
-
1][j];
}
for
(int
i
=
0;
i
<=
ROW;
i++)
{
for
(int
j
=
0;
j
<=
a[i].length
-
1;
j++)
System.out.print(a[i][j]
+
"\t");
System.out.println();
}
}
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
public class Test
{
public static void main(String[] args)
{
int i=0;
int j=0;
int a[][]=new int[10][10];
for( i=0;i<10;i++)
{ a[i][0]=1;
}
for(i=1;i<10;i++)
{ for(j=1;j<i;j++)
{ a[i][j]=a[i-1][j-1]+a[i-1][j];
}
}
for(int m=0;m<10;m++)
{ for(int n=0;n<10;n++)
{ if (a[m][n]!=0)
{
System.out.print(a[m][n]+" ");
}
}
System.out.println();
}
}
}
{
public static void main(String[] args)
{
int i=0;
int j=0;
int a[][]=new int[10][10];
for( i=0;i<10;i++)
{ a[i][0]=1;
}
for(i=1;i<10;i++)
{ for(j=1;j<i;j++)
{ a[i][j]=a[i-1][j-1]+a[i-1][j];
}
}
for(int m=0;m<10;m++)
{ for(int n=0;n<10;n++)
{ if (a[m][n]!=0)
{
System.out.print(a[m][n]+" ");
}
}
System.out.println();
}
}
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询