Arone
Arone
CC#
Created by Arone on 10/12/2023 in #help
✅ How would i print a string value into this 2d array?
const int shipGridWidth = 5; const int shipGridHeight = 9; int[,] shipGrid = new int[shipGridWidth, shipGridHeight]; for (int y = 0; y < shipGridHeight; y++) { for (int x = 0; x < shipGridWidth; x++) { if (y == 0) shipGrid[x, y] = x+1; // Populate header index else { if (x == 0) shipGrid[x, y] = y + 1; // Populate row index else { //populate playing board shipGrid[x, y] = 0; shipGrid[2, 4] = 5; } } } } //Print Grid for (int y = 0; y < shipGridHeight; y++) { for (int x = 0; x < shipGridWidth; x++) { Console.Write("{0,6}",shipGrid[x, y]); } Console.WriteLine(); } Console.ReadLine();
7 replies
CC#
Created by Arone on 10/2/2023 in #help
❔ Array mess
No description
22 replies