this is the code. how have you done that so the 1 doesn't shift everything??
Code:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define ROW 9
#define COL 9
char image[1][ROW][COL];
// COL
// +----+
// | | ROW
// | |
// +----+
//
// 5x5 O and O images
char shapes[2][5][6] = { { "*****"
, "* *"
, "* *"
, "* *"
, "*****" }
, { "*****"
, "* *"
, "* *"
, "* *"
, "*****" }
};
void rectange()
{
for(int k = 0; k < 2; k++)
for(int r = 0; r < ROW; r++)
for(int c = 0; c < COL; c++)
{
image[k][r][c] = ' ';
int top = (r == 0);
int bottom = (r == ROW - 1);
int left = (c == 0);
int right = (c == COL - 1);
// corner
if ((top || bottom) && (left || right))
image[k][r][c] = '+';
else
// top or bottom
if (top || bottom) image[k][r][c] = '-';
else
// left or right
if (left || right) image[k][r][c] = '|';
}
}
void overlay_X_or_O()
{
for(int k = 0; k < 2; k++)
{
int shape = rand() % 2;
for(int r = 0; r < 5; r++)
for(int c = 0; c < 5; c++)
image[k][r + 2][c + 2] = shapes[shape][r][c];
}
}
int main()
{
srand(time(NULL)); // initialise random number generator
rectange(); // initialise the image with a rectange
overlay_X_or_O(); // overlay image of O or O on top
// int num = (rand() % 6 +1);
// sprintf(roll_num, "%d", (rand() % 6 +1));
// printf("RANDOM = %s", roll_num);
//board[i_coord][j_coord]= O_mark;
//image[1][4][4] = roll_num;
char numers[6] = {'1','2','3','4','5','6'};
image[0][4][4] = numers[(rand() % 6 + 1)];
image[1][4][4] = numers[(rand() % 6 + 1)];
// print the image
for(int r = 0; r < ROW; r++)
{
for(int k = 0; k < 2; k++)
{
for(int c = 0; c < COL; c++)
printf("%c", image[k][r][c]);
printf(" ");
}
printf("\n");
}
return 0;
}