Hello :)我编写了一个程序,用户在其中给出数组的大小,然后给出其参数。如果输入大小5,程序将要求您输入5个参数,等等。问题是程序不接受大于8的大小。如果我输入数组的大小为9,则程序必须还是写8个参数。我在做什么错?
#include <iostream>
using namespace std;
int main()
{
int argument, array[argument], i;
cout << "Enter the size of the array: ";
cin >> argument;
int *board = new int[ argument ];
for (i=0;i<argument;++i)
{
cout <<"Enter "<<i+1<<". element of the array: ";
cin >>array[i];
cin.ignore();
}
cout <<endl<<"Here is the board: ";
for (i=0;i<argument;++i)
cout <<array[i]<<' ';
delete[] board;
return 0;
}
我会在for循环中尝试使用i ++而不是++ i。看不到其他任何问题。