如何找到列的总和?我只知道如何找到行和的总和 整体总数
对不起我还是新手大学新生程序员
感谢任何可以帮助我的人!
这是我的代码:
#include <iostream>
using namespace std;
int main()
{
int row, column, rowsum=0, total=0, number1=1, number2=1;
int rowcol[5][5];
{
for (row = 0; row < 5; row++)
{
for (column = 0; column < 5; column++)
{
cout << "Enter employee no." << number1 << " salary: ";
cin >> rowcol[row][column];
}
number1 = number1 + 1;
}
for (row = 0; row < 5; row++)
{
rowsum = 0;
for (column = 0; column < 5; column++)
{
rowsum = rowsum + rowcol[row][column];
}
cout << "Total salary of employee no." << number2 << ": " << rowsum << endl;
number2 = number2 + 1;
}
for (row = 0; row < 5; row++)
{
for (column = 0; column < 5; column++)
{
total = total + rowcol[row][column];
}
}
cout << "Total salary of all employees: " << total;
}
system("pause>0");
return 0;
}