Info

Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.

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

1 Ansicht (letzte 30 Tage)
Shawn Blancett
Shawn Blancett am 15 Sep. 2017
Geschlossen: Walter Roberson am 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 Kommentar
Shawn Blancett
Shawn Blancett am 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

Antworten (0)

Diese Frage ist geschlossen.

Community Treasure Hunt

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

Start Hunting!

Translated by