Thread: tell me and we will both know

  1. #1
    Registered User
    Join Date
    Oct 2001
    Posts
    6

    Talking tell me and we will both know

    I have a 2D array[25][50] that reads in a file with $ chars only in it.

    I need to check a char "$" to see if it has any "$" characters in adjoining cells. What kind of coding would I use to find this? I'm stumped. Surely c++ must get easier.

  2. #2
    Fingerstyle Guitarist taylorguitarman's Avatar
    Join Date
    Aug 2001
    Posts
    564
    do you mean something like points in a grid? I did a program once that counted the number of "blobs" (adjacent '*'s) in a nXm grid.
    if I remember correctly loop through the grid looking for an occupied cell, once found delete the contents of it and use a recursive function to check each of the surrounding cells, each time deleting the contents and again calling the recursive function. keep making passes through the grid until there are no more occupied cells. make sure you make a duplicate array incase you need to output it again. I have the code lying around somewhere if you'd like it or have any other questions.

  3. #3
    Registered User
    Join Date
    Oct 2001
    Posts
    6

    fantastic

    It sounds the same as the one I need to do. If you have a spare copy could you email me, your a life saver. I could kiss your feet.


  4. #4
    Fingerstyle Guitarist taylorguitarman's Avatar
    Join Date
    Aug 2001
    Posts
    564
    here it is. forgive me for the lack of commenting but i think you'll be able to figure it out.
    you'll have to modify it a bit for your specs but it's just minor changes.

Popular pages Recent additions subscribe to a feed