主题:为什么老是提示数组越界
using System;
namespace Project2
{
/// <summary>
/// Class2 的摘要说明。
/// </summary>
public class Class2
{
static void Main()
{
int n,i;
n=Console.Read();
int []a=new int[n];
a[1]=1;
a[2]=1;
Console.Write("{0},{1},",a[1],a[2]);
for( i=3;i<=n;i++)
{ a[i]=a[i-2]+a[i-1];
Console.Write("{0},",a[i]);
}
Console.WriteLine();
}
}
}
namespace Project2
{
/// <summary>
/// Class2 的摘要说明。
/// </summary>
public class Class2
{
static void Main()
{
int n,i;
n=Console.Read();
int []a=new int[n];
a[1]=1;
a[2]=1;
Console.Write("{0},{1},",a[1],a[2]);
for( i=3;i<=n;i++)
{ a[i]=a[i-2]+a[i-1];
Console.Write("{0},",a[i]);
}
Console.WriteLine();
}
}
}