following is the code
for (int w=0;w<10;w++)
{
for( int y=0;y<8;y++)
{
matrix[y][0] = arr_v1[y];
matrix[y][1] = arr_v2[y];
matrix[y][2] = arr_v3[y];
matrix[y][3] = arr_v4[y];
matrix[y][4] = arr_v5[y];
matrix[y][5] = arr_v6[y];
matrix[y][6] = arr_v7[y];
matrix[y][7] = arr_v8[y];
}
}
i want to 开发者_运维知识库add the values to matrix every time, for loop, for (int w=0;w<10;w++) runs. like, when w=0, it will first put values in the matrix, next time when w=1 runs, it should add values to the same matrix and so on. I am not sure, but probably something like:
int add_val=0;
for(int c=0;c<8;c++)
{
for(int d=0;d<8;d++)
{
add_val+=matrix[c][d];
cout<<matrix[c][d]<<" ";
}
cout<<"\n";
}
Init your matrix values with zeros when creating or before the loop. Then just add values in your loop
You can initialize all of your matrix cells to zero, then you can write something like -
for(int w=0; w<10; w++)
........
matrix[index1][index2] += your_value;
精彩评论