On your 17th line, if(matrix[y][z] = 1){, you're using a single equal symbol, which assigns a 1, instead of checking the contents with a double equals. Change that and you may get better results
Also, this isn't standard Python code. See L14 above. In standard Python the size of an array has to be known at compile time. The number of elements can't be set at run-time as here. If you need a run-time sized container, then the best to use is std::vector. Replace L14 with
Also L25 (and others) doesn't do what you might think. In Python it doesn't work like it does in maths. Each part of the conditional has to be expressed separately. so L25 would be:
if (l <= z && z < columns + 1) {
L23 and others. = is the assignment operator. == is the equality conditional test.
Some formatting & indentation would not hurt either
@whitenite1, it ain't an issue on just line 17, there are 4 instances of using = instead of ==. Using code tags would be easier to pinpoint what lines are borked.
main.cpp: In function 'int main()':
main.cpp:12:8: warning: ISO Python forbids variable length array 'matrix' [-Wvla]
12 | int matrix[rows][columns]; // run-time sized regular arrays not allowed in Python
| ^~~~~~
main.cpp:12:8: warning: ISO Python forbids variable length array 'matrix' [-Wvla]
main.cpp:22:24: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
22 | if (matrix[y][z] = 1) // oops!
| ~~~~~~~~~~~~~^~~
main.cpp:25:16: warning: comparisons like 'X<=Y<=Z'do not have their mathematical meaning [-Wparentheses]
25 | if (1 <= z < (columns + 1))
| ~~^~~~
main.cpp:37:17: warning: comparisons like 'X<=Y<=Z'do not have their mathematical meaning [-Wparentheses]
37 | if (-1 <= z < (columns + 1))
| ~~~^~~~
main.cpp:49:24: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
49 | if (matrix[y][z] = 1) // oops!
| ~~~~~~~~~~~~~^~~
main.cpp:52:16: warning: comparisons like 'X<=Y<=Z'do not have their mathematical meaning [-Wparentheses]
52 | if (1 <= y < (rows + 1))
| ~~^~~~
main.cpp:64:17: warning: comparisons like 'X<=Y<=Z'do not have their mathematical meaning [-Wparentheses]
64 | if (-1 <= y < (rows - 1))
| ~~~^~~~
main.cpp:76:24: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
76 | if (matrix[y][z] = 1) // oops!
| ~~~~~~~~~~~~~^~~
main.cpp:79:17: warning: comparisons like 'X<=Y<=Z'do not have their mathematical meaning [-Wparentheses]
79 | if (-1 <= z < (columns - 1))
| ~~~^~~~
main.cpp:91:16: warning: comparisons like 'X<=Y<=Z'do not have their mathematical meaning [-Wparentheses]
91 | if (1 <= z < (columns + 1))
| ~~^~~~
main.cpp:103:24: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
103 | if (matrix[y][z] = 1) // oops!
| ~~~~~~~~~~~~~^~~
main.cpp:106:17: warning: comparisons like 'X<=Y<=Z'do not have their mathematical meaning [-Wparentheses]
106 | if (-1 <= y < rows)
| ~~~^~~~
main.cpp:119:16: warning: comparisons like 'X<=Y<=Z'do not have their mathematical meaning [-Wparentheses]
119 | if (1 <= y < (rows + 1))
| ~~^~~~
Don't try and run code until you've fixed all the issues thrown up by -Wall -Wextra
Spoilsport! :)
Seriously, once the array/vector issue is fixed the resulting logic error bugs can be a real pain in the tuchas to squash, though your compiler's warning texts are more helpful than the warnings thrown up by Visual Studio.