我希望完成这个课程的课程。当涉及到数组时,我迷失了方向,我已经阅读了所有课程作业、书籍等。问题是如何在该位置增加二维数组元素?
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;
}