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!