求教杨辉三角编程错误
import *;public class O
{
public static void main(String[] args)throws IOException
{
BufferedReader keyin=new BufferedReader(new InputStreamReader(System.in));
int temp,i;
String c;
System.out.print("请输入所需行数:");
c=keyin.readLine();
temp=Integer.parseInt(c);
if(temp<=0)
System.out.println("您输入的数没意义!");
else if(temp==1)
{
int b[]=new int[1];
b[0]=1;
System.out.println(b[0]);
}
else if(temp==2)
{
System.out.println("1"+'\n'+"1"+"1");
}
else
{
int a[][]=new int[temp][];
for(i=1;i<=temp;i++)
{
a[i-1]=new int[i];
}
a[0][0]=a[1][0]=a[1][1]=a[temp-1][0]=1;
int p,q;
for(p=2;p<=temp;p++)
{
for(q=1;q<p;q++)
a[p][q]=a[p-1][q-1]+a[p-1][q]; //此行出现错误!
}
System.out.println("1"+'\n'+"1"+"1");
for(p=2;p<=temp;p++)
{
for(q=0;q<p;q++)
System.out.print(a[p][q]);
System.out.println("1");
}
}
}
}
编译能通过,但输入3后出现错误