Info

Cette question est clôturée. Rouvrir pour modifier ou répondre.

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

1 vue (au cours des 30 derniers jours)
Shawn Blancett
Shawn Blancett le 15 Sep 2017
Clôturé : Walter Roberson le 15 Sep 2017
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 commentaire
Shawn Blancett
Shawn Blancett le 15 Sep 2017
In the code, 8 is the symbol for attacked 1 is the symbol for queen and 0 is the symbol for empty space

Réponses (0)

Cette question est clôturée.

Community Treasure Hunt

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

Start Hunting!

Translated by