#include <iostream>
const int a = 5;
const int b = 5;
const int c = 5;
void fun1(int j, int (*num)[c])
{
for (int k = 0; k < c; k++) // loop c
{
num[j][k]++;
}
}
int main()
{
for (int j = 0; j < a; j++) { //loop a
int num[a][c] = { 0 };
for (int i = 0; i < b; i++) //loop b
{
fun1(j, num);
}
for (auto j = 0; j < a; i++) {
for (auto i = 0; i < b; i++) {
std::cout << j << ", " << j << ": " << num[j][b] << std::endl;
}
}
}
return 0;
}
我希望对于不同i相同k的num[j][k]数值能够相加,比方j=0,i=0,k=0时num[0][0];j=0,i=1,k=0 时num[0][0]两者相加,在之后j=1时num[a][c]又归0,请问如何实现呢?