私はクラスのためにこのプログラムを完成させようとしています。配列に関してはよくわからず、すべてのコースワークや本などを読みました。問題は、その位置で 2 次元配列要素をどのように増やすかです。
int main()
{
int quantity, warehouse, product;
int inventory[4][5] = {
{900,400,250,95,153},
{52, 95, 625, 44, 250},
{100,720,301,50,878},
{325,650,57,445,584},
};
cout << "Enter the warehouse number between 1 and 4: " << endl;
cin >> warehouse;
cout << "Enter the product location between 1 and 5: " << endl;
cin >> product;
cout << "Enter the quantity delivered: " << endl;
cin >> quantity;
/* First the addition */
for(warehouse = 0; warehouse < 4; warehouse++)
for(product = 0; product < 5; product++)
inventory[warehouse][product] + quantity;
cout << "The amount of units in warehouse " << warehouse << " is \n\n";
/* Then print the results */
for(warehouse = 0; warehouse < 4; warehouse++ ) {
for( product = 0; product < 5; product++ )
cout << "\t" << inventory[warehouse][product];
cout << endl; /* at end of each warehouse */
}
return 0;
}