I think its easy question! I have 2 dimension array with 0 for all element! now in each iteration I want to make one of the column equal to 1! for example: input={{0,0},{0,0}} out put:={{1,0},{1,0}} ,{{0,1},{0,1}} I wrote this code but I get very strange result!!!!
int main() {
int j = 3;
int arr[5][j] = { 0 };
int dx = 0;
for (int g = 0; g < j; g++) {
for (int t = 0; t < 5; t++) {
arr[t][g] = 1;
}
dx = g;
for (int d = 0; d < 5; d++) {
for (int n = 0; n < j; n++) {
cout << arr[d][n] << " ";
}
cout << endl;
}
cout << "next column=0" << " " << endl;
}
return 0;
}
the out put is:
1 -1 64
1 2 0
1 0 4272944
1 65535 0
1 0 56
next column=0
1 1 64
1 1 0
1 1 4272944
1 1 0
1 1 56
next column=0
1 1 1
1 1 1
1 1 1
1 1 1
1 1 1
next column=0