Info
この質問は閉じられています。 編集または回答するには再度開いてください。
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 回表示 (過去 30 日間)
古いコメントを表示
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 件のコメント
回答 (0 件)
この質問は閉じられています。
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!