First Upload
This commit is contained in:
37
Projects/LifeGame/checkthis.c
Normal file
37
Projects/LifeGame/checkthis.c
Normal file
@@ -0,0 +1,37 @@
|
||||
void AddOneToNeighbors(int * ptr_mat, int * ptr_loc, unsigned int row_size, unsigned int col_size)
|
||||
{
|
||||
int * ptr_last = ptr_mat + (row_size * col_size);
|
||||
int * ptr_temp = ptr_loc - col_size - ONE;
|
||||
for (unsigned short count = ZERO; count < THREE; count++)
|
||||
{
|
||||
if (ptr_temp >= ptr_mat &&
|
||||
((int)ptr_temp / sizeof(int)) / row_size == ((((int)ptr_loc / sizeof(int)) / row_size) - ONE))
|
||||
{
|
||||
(*(ptr_temp))++;
|
||||
}
|
||||
ptr_temp++;
|
||||
}
|
||||
|
||||
ptr_temp = ptr_loc - ONE;
|
||||
for (unsigned short count = ZERO; count < TWO; count++)
|
||||
{
|
||||
if (ptr_temp >= ptr_mat &&
|
||||
ptr_temp < ptr_last &&
|
||||
((int)ptr_temp / sizeof(int)) / row_size == ((((int)ptr_loc / sizeof(int)) / row_size)))
|
||||
{
|
||||
(*(ptr_temp))++;
|
||||
}
|
||||
ptr_temp += TWO;
|
||||
}
|
||||
|
||||
ptr_temp = ptr_loc + col_size - ONE;
|
||||
for (unsigned short count = ZERO; count < THREE; count++)
|
||||
{
|
||||
if (ptr_temp < ptr_last &&
|
||||
((int)ptr_temp / sizeof(int)) / row_size == ((((int)ptr_loc / sizeof(int)) / row_size) + ONE))
|
||||
{
|
||||
(*(ptr_temp))++;
|
||||
}
|
||||
ptr_temp++;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user