Hello! Trying to figure out why my grid for my memory game won’t generate, I have all the code ready and it compiles. Heres my code…
// ----------------------------------------------
// Program Name: Memory
// Program Number: 5
// Submitted by: Chris Duncan
//
//
// By submitting this program with my name, I affirm that the creation and
// modification of this program is primarily my own work.
// ----------------------------------------------
#include “stdio.h”
#include “stdlib.h”
#include “memory.h”
#include “time.h”
void Generate(int grid[5][6]);
void display(int grid [5][6],int matched [5][6]);
int main()
{
int grid[5][6];
int matched[5][6];
int i=0, j=0;
int r = r % 5;
int c = c % 6;
// Generate the matched grid
for (i=0; i<5; i++)
{
for (j=0; j<6; j++)
{
if (i==0 || j==0 || i==j)
{
matched*[j] = 0;
} // end of if
else
{
matched*[j] = 1;
} // end of else
} // end of for j
} // end of for i
// Display the grid
// Display(grid, matched);
system("pause");
} // end of main()
// Generate the grid
Generate(grid);
// Algorithm for Program 5
void Generate(int grid[5][6])
{
int row, column = 0;
int r = 0, i = 0, j = 0;
// Fill grid with value 0
// Loop through rows
for ( i = 0; i < 5; i++ )
{
// Loop through the columns
for ( j = 0; j < 6; j++ )
{
// Store the value 0 at the current position
grid*[j] = 0;
}// end of loop
}// end of loop
srand(time (NULL));
// Loop 15 times
for (i=0; i<15; i++)
// Generate a random number 1 - 99
r = rand();
r = (r - 0) * (100 - 1) / (RAND_MAX - 0) + 1;
// Loop as long as position picked contains a value
do
{
// Pick a random row
row = rand() % 5;
// Pick a random column
column = rand() % 6;
} while (grid [row] [column] !=0);// end of loop
// Store the value at the chosen location
grid[row] [column] = r;
// Loop as long as position picked contains a value
do
{
// Pick a random row
row = rand() % 5;
// Pick a random column
column = rand() % 6;
} while (grid [row] [column] !=0);// end of loop
{
// Store the value at the chosen location
grid[row] [column] = r;
}// end of loop
}// end of function
void display(int grid [5][6],int matched [5][6])
{
int i=0, j=0;
for (i = 0; i < 5; i++)
{
for (j = 0; j < 6; j++)
{
if (matched*[j] == 0)
{
printf("%c", 177);
} // end of if
else
{
printf("%i", grid*[j]);
} // end of else
} // end of loop
} // end of loop
} // end of function
now the “generate(grid);” is suppose to make my 5 by 6 grid appear, but when I compile its just a blank screen. So, how do I fix this?