Azzera filtri
Azzera filtri

Info

Questa domanda è chiusa. Riaprila per modificarla o per rispondere.

How can I create a battleship game board with a variable size as a char array so that I can edit certain elements of it?

1 visualizzazione (ultimi 30 giorni)
So I have the user input the size of the board they want to play on and I figured out how to do it using for loops and fprintf statements, but I need what this code produces but in an array of type char, can anyone help me out? I need a board that will look exactly like the one that my code produces below, but as a char array.
if true
%Create the visible board
%for loop creating first row of the board
fprintf ('\n- ')
for i = 1:Size
fprintf (' %d ', i);
end
fprintf ('\n')
%for loop creating the rest of the rows of the board
for j = 1:Size
fprintf ('%d', j)
for j = 1:Size
fprintf (' .')
end
fprintf ('\n')
end
end

Risposte (0)

Questa domanda è chiusa.

Community Treasure Hunt

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

Start Hunting!

Translated by