题目描述
用vs编写c++的时候,总是有关于数组的一个问题,麻烦各位大牛帮忙看一下
题目来源及自己的思路
相关代码
include <iostream>
include <iomanip>
using namespace std;
int main( )
{
const int arry = 200;
int Fibonacci[arry] =
{
1, 1
};
int n;
cin >> n;
for (int i = 2; i < n; i++)
{
Fibonacci[i] = Fibonacci[i - 2] + Fibonacci[i - 1];
}
for (int j = 1; j <= 20; j++)
{
cout << setw(6);
cout << Fibonacci[j - 1];
cout << ((j % 5)? "" : "\n");
}
cout << endl;
system("pause");
return 0;
}
你期待的结果是什么?实际看到的错误信息又是什么?
错误为:
C26482 Only index into arrays using constant expressions (bounds.2)
C26446 Prefer to use gsl::at() instead of unchecked subscript operator (bounds.4)