Вот что у меня сейчас есть:
Код: Выделить всё
#include
using namespace std;
int main()
{
char array[8][8] = {
{'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O'},
{'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O'},
{'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O'},
{'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O'},
{'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O'},
{'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O'},
{'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O'},
{'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O'},
};
srand(time(NULL));
for (int i = 0; i < 2; i++) {
array[rand() % 5][rand() % 5] = 'J';
}
//print the grid
for (int i = 0; i < 8; i++)
{
for (int j = 0; j < 8; j++)
{
cout
Подробнее здесь: [url]https://stackoverflow.com/questions/78368743/how-do-i-get-the-position-of-an-object-in-a-2d-array-in-c[/url]