我期待完成此课程的课程。我在数组中遇到了问题,并且我已经阅读了所有的课程,书籍等。问题是如何在该位置增加一个二维数组元素?C++二维数组值增加
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;
}
谢谢你们。这非常有意义,我的程序完美无缺。我想知道为什么阅读这本书是浪费时间。 – 2013-05-12 00:00:26