Использование массивов Dyanmic намного быстрее, чем многомерных, но используйте последний, если это проще, и вы знаете значения. Предполагая, что вы знаете значения каждого целого числа в поле, похоже, у вас есть [5] [5] двумерный массив. Использование .NET и C ++ где-то хорошо для начала было бы:
#include <iostream>
#include <vector>
using namespace std;
int main()
{
vector <int> DynArrNums(25);
DynArrNums[0] = //Put any value here which you know for the rules of your game as a number;
DynArrNums[1] = 1001;
DynArrNums[2] = 1002;//Put any value here which you know for the rules of your game as a number;
DynArrNums[3] = 1003;//Put any value here which you know for the rules of your game as a number;
DynArrNums[4] = 1004;//Put any value here which you know for the rules of your game as a number;
DynArrNums[5] = 1005;//Put any value here which you know for the rules of your game as a number;
DynArrNums[6] = 1006;//Put any value here which you know for the rules of your game as a number;
DynArrNums[7] = 1007;//Put any value here which you know for the rules of your game as a number;
DynArrNums[8] = 1008;//Put any value here which you know for the rules of your game as a number;
DynArrNums[9] = 1009;//Put any value here which you know for the rules of your game as a number;
DynArrNums[10] = 1010;//Put any value here which you know for the rules of your game as a number;
DynArrNums[11] = 1011;//Put any value here which you know for the rules of your game as a number;
DynArrNums[12] = 1012;//Put any value here which you know for the rules of your game as a number;
DynArrNums[13] = 1013;//Put any value here which you know for the rules of your game as a number;
DynArrNums[14] = 1014;//Put any value here which you know for the rules of your game as a number;
DynArrNums[15] = 1015;//Put any value here which you know for the rules of your game as a number;
DynArrNums[16] = 1016;//Put any value here which you know for the rules of your game as a number;
DynArrNums[17] = 1017;//Put any value here which you know for the rules of your game as a number;
DynArrNums[18] = 1018;//Put any value here which you know for the rules of your game as a number;
DynArrNums[19] = 1019;//Put any value here which you know for the rules of your game as a number;
DynArrNums[20] = 1020;//Put any value here which you know for the rules of your game as a number;
DynArrNums[21] = 1021;//Put any value here which you know for the rules of your game as a number;
DynArrNums[22] = 1022;//Put any value here which you know for the rules of your game as a number;
DynArrNums[23] = 1023;//Put any value here which you know for the rules of your game as a number;
DynArrNums[24] = 1024;//Put any value here which you know for the rules of your game as a number;
cout << "Enter another number for the array" << endl;
int AnotherNum = 0;
cin >> AnotherNum;
DynArrNums.push_back(AnotherNum);
cout << "Number of integers in array: " << DynArrNums.size() << endl;
cout << "Last element in array: ";
cout << DynArrNums[DynArrNums.size() - 1] << endl;
return 0;
}
Помните, что первый массив хранится как 0, поэтому в конце необходим минус 1. Я только что попробовал, и это работает:)
Однако динамическому массиву не нужно знать, что пропущенное целое число является средней панелью массива, просто нужно знать, что вы добавляете еще одну. Конечно, это делает его настраиваемым для вашей игры, и вы можете поставить любое значение. В этом случае он добавляет его в конец, и вы можете вызвать любое значение по его последовательности в массиве.
Чтобы найти число [0], первая панель [1] является следующей панелью. Поэтому [6] будет первой панелью второй строки [11] будет первой панелью в третьей строке и т. Д.
Наконец, DynArrNums [25] не означает, что у вас есть 25 заполненных полей. Это просто означает, что на вашей панели их 25 блоков, и код знает, что их нет, поэтому в конце запрашивает их.
Удачи.