Info
La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.
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 visualización (últimos 30 días)
Mostrar comentarios más antiguos
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
1 comentario
Respuestas (0)
La pregunta está cerrada.
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!