Thread: Counting shapes

  1. #1
    Registered User
    Join Date
    Mar 2008
    Posts
    22

    Counting shapes

    I have couple of text files with some drawn shapes made of . and +
    for example:
    ........................................
    .........+++.........................
    .........+++.......+++++......
    .........+++........+++++.....
    .........+++.......+++++......
    ....................++++...........
    ....+++++.........+++.........
    ...+++.+++.......................
    ...+++.+++...........++.......
    ...+++.+++...........++.......
    ....+++++........................
    .......................................
    I am reading this text file info an 2D array.
    Looking at the example I see 4 shapes made of +

    But how how can I count them inside my program?
    Can you guys give me an idea how to construct a counter of how many shapes (made of +) are present.

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Look for a +. Add one to shape_count, and turn every + connected to that + into a . Repeat until finished.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. [C] drawing: drag GDI shapes
    By pc2-brazil in forum Windows Programming
    Replies: 3
    Last Post: 10-05-2008, 02:06 PM
  2. How to implement reference counting with 'Smart_ptr'?
    By meili100 in forum C++ Programming
    Replies: 3
    Last Post: 06-10-2007, 05:28 AM
  3. Counting Numbers in Array, not counting last number!
    By metaljester in forum C++ Programming
    Replies: 11
    Last Post: 10-18-2006, 11:25 AM
  4. Universal area forumula for equilateral + equiangular shapes?
    By Bird Killer in forum A Brief History of Cprogramming.com
    Replies: 4
    Last Post: 03-05-2006, 02:55 PM
  5. Program with Shapes using Virtual Functions
    By goron350 in forum C++ Programming
    Replies: 12
    Last Post: 07-17-2005, 01:42 PM