0

i have to make a two players snake and ladder game in c++, in which i have to display the board aswell. i donot know should i use set(w) statment and cout my board or should i go for arrays? n if i do it using arrays, how to show where the snankes and where the ladder lies? please help. Thank you.

2
Contributors
2
Replies
3
Views
5 Years
Discussion Span
Last Post by marino07
0

I would create an array (say board[])
from that array if it was 0 it would be a standard place (no snake or ladder)
if it was a positive number then it would be a slide (and advance the piece) if negative then it would a snake

and draw the board manually

for display function i would use % (modulus) to find the line to print on

0

thank you for replying. actually, i am a new learner and i donot have much knowledge. when i display the board on screen i have to mention where is the snake and where is a ladder. i tried to do it using "setw " but it causes trouble in the board alignment. by using arrays i donot know how to accomodate char type "snake" or "ladder" in an aaray. :( i am doing something like this :

{
int array1[1][20]={{100,99,98,97,96,95,94,93,92,91,81,82,83,84,85,86,87,88,89,90}};

for (int i=0;i<1;i++)
{   for (int j=0; j<20;j++)
    {
cout << array1[i][j]<<"\t";
if(array1[i][j]==array1[0][10])
        cout<< "snake";
}

}
cout << endl;
return 0;
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.