Public Group

# Find field borders

This topic is 2788 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hello guys,

so I got paid (pack of cigarettes, I feel like a pro programmer now^_^) and now the task is simple representation of Conway's Game of Life. I've completed the task, but there's one thing that lies in my mind - one of the tasks is, that borders of the array (2D or vector, I've done in with vector) have to stay empty (or dead, if you wish) all the time. It's 20x20 array, so I decided to do it the old-fashioned way and wrote down all the coordinates which are at the borders (I guess 72)... but what if I want to multiply the size of my array by two? Then I would have to write down another 72 numbers and I would need to do this every time I change the size. That's why I've been thinking about some function, that would find the borders by itself and store them somewhere, so no matter how the array is big, it will always find them for me. Any ideas?

So far I've been able to detect only vertical ones with something like:
//I'm printing 'x' where the border isfor(int i = 0; i < pole.size(); ++i){		if((i + 1) % 20 == 0){			pole = 'x';		}		if(i % 20 == 0){			pole = 'x';		}	}

Thanks for any ideas.

1. 1
2. 2
Rutin
22
3. 3
4. 4
JoeJ
15
5. 5

• 14
• 30
• 13
• 11
• 11
• ### Forum Statistics

• Total Topics
631776
• Total Posts
3002300
×