Aside from your current attempt I think you need to determine what is meant by adjacent. In a two dimensional array an element can be seen to have as many as 8 adjacent values: above left, above, above right, left, right, below left, below, and below right. You're only considering the two values in the same row.
17 Replies - 547 Views - Last Post: 18 December 2012 - 07:03 AM
#16
Re: Identifing an isolated character in a matrix
Posted 18 December 2012 - 06:46 AM
#17
Re: Identifing an isolated character in a matrix
Posted 18 December 2012 - 06:49 AM
I'm considering the same situation described by you.
Doesn't the code work with that?
Doesn't the code work with that?
#18
Re: Identifing an isolated character in a matrix
Posted 18 December 2012 - 07:03 AM
So you are! Sorry, I misread a post or two.
When I ran your latest version I got this:
So it appears to be working, but you need to test more.
I'd have the matrix read in from a file. That way you could change file names for different tests, allowing you to check situations with 1s in corners, sides, and the middle.
When I ran your latest version I got this:
Enter the number of rows of the matrix associated to the bitmap: 4 Enter the number of columns of the matrix associated to the bitmap: 4 Enter the element [0][0]: 1 Enter the element [0][1]: 0 Enter the element [0][2]: 0 Enter the element [0][3]: 0 Enter the element [1][0]: 0 Enter the element [1][1]: 1 Enter the element [1][2]: 0 Enter the element [1][3]: 0 Enter the element [2][0]: 0 Enter the element [2][1]: 0 Enter the element [2][2]: 0 Enter the element [2][3]: 0 Enter the element [3][0]: 0 Enter the element [3][1]: 0 Enter the element [3][2]: 0 Enter the element [3][3]: 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 The bitmap does not contain an isolated point.
So it appears to be working, but you need to test more.
I'd have the matrix read in from a file. That way you could change file names for different tests, allowing you to check situations with 1s in corners, sides, and the middle.
|
|

New Topic/Question
Reply





MultiQuote


|