Info

此问题已关闭。 请重新打开它进行编辑或回答。

How can I change rows and and diagonals in an array of size NxN

1 次查看(过去 30 天)
Below is the code im starting for a "queens project" where you place queens on a board so they cant attack eachother, My professor said that there was a tool I could use where once I found a queen in my board that I could change all the queens in that column to show it was "attacked" by using the "*" function but it isnt working when I do it.
Any ideas?
it should be line 12 where im having the issues
N = input('boardsize ')
X = zeros(N);
for k=1:N
random = randi([1,N]);
X(k,random) = 1;
end
X
index = find([X] == 1)
for i = 1:N
for j = 1:N
if(X(i,j) == 1)
X(*,j) = 8// trying to figure out
end
end
end
  1 个评论
Shawn Blancett
Shawn Blancett 2017-9-15
In the code, 8 is the symbol for attacked 1 is the symbol for queen and 0 is the symbol for empty space

回答(0 个)

此问题已关闭。

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by