How do I add letters from A-Y in random places in a 2d array that has 50 columns and 10 rows?
void playersgrid(char two[GRIDY][GRIDX]) //, char three[PLAYERCNT])
{
int a,b;
for(int i=0;i<GRIDY;i++)
{
for(int j=0; j<GRIDX; j++)
{
a=rand()%GRIDY;
b=rand()%GRIDX;
if(ALIVE)
two[a][b]=0;
//two[i][j]=0;
}
}
/* for(int i= 0 ;i < PLAYERCNT;i++)
{
a = rand()%GRIDY;
b = rand()%GRIDX;
two[a][b]= three[i];
if(two[a][b]==0)
cout <<" ";
else
cout << three[i];
}*/
example:
-----------------------------------Q-------------------------------
------------------------------------------C-------------------------
--------------------------------------------------------------------
-------------D------------------------------------------------------
------------------------------------------------------------------RN
--------------------E--------X-F------------------------------------
---------------------L --------------------------S------------------
----------Y ----------------G-----------------------H---------------
--------------------------------------J------------------K-----------
-----T ----------------I----------------------------------------------
----------P ------------------- O --------------W--------------------
---U----------------------------------V-----------------------------
---------------------------------------------------------------- B----
----------------------------------------- A---------------------------
Last edited on