Topic: 程序输出有问题(杨晖三角10行输出)

  Print this page

1.程序输出有问题(杨晖三角10行输出) Copy to clipboard
Posted by: ddddddv
Posted on: 2007-02-21 21:31

public class YangHui {
public static void main(String[] args) {
int[][] Tarry={ };
for(int i=0;i<10;i++) {
for(int j=0;j<=i;j++) {
if(j>0 && j<i) {
Tarry[i][j]=Tarry[i-1][j-1]+Tarry[i-1][j];
} else {
Tarry[i][j]=1; }
System.out.println("Tarry[i][j]"+" "); }
System.out.println(); }
}
}
我写的程序如上
出现下面的问题

2.Re:程序输出有问题(杨晖三角10行输出) [Re: ddddddv] Copy to clipboard
Posted by: JiafanZhou
Posted on: 2007-02-22 06:57

Look at your exception here.. ArrayIndexOutOfBoundsException, at your YangHui.class line9...It is a very very simple Java program. Now what the job left for you to do is to find out why this is out of bound. Don't look at me, I am not going to do that for ye...

Regards,
Jiafan

3.Re:程序输出有问题(杨晖三角10行输出) [Re: ddddddv] Copy to clipboard
Posted by: why
Posted on: 2007-02-22 19:25

int[][] tarry = new int[10][10];


   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923