Alternative Methods ...


Results 1 to 4 of 4

Threaded View

  1. #4
    T.Jackson's Avatar
    T.Jackson Guest


    Did you find this post helpful? Yes | No

    Default

    Code:
    public int getObjectsAtSameDistance()
    {   
       int ObjectsSameDistance;
    
       // Scan thru array and see how many objs are at the same distance
       for (int j = 0, j < 2, j++)
       {
          for (int i = j + 1, i < 2, i++)
          {
             if (distances[j] == distances[i])
             {
                objectsSameDistance ++;
                break; 
             }
          }
       }
    
       if (objectsSameDistance > 0)
          objectsSameDistance ++;
    
       return objectsSameDistance;
    }
    There is actually a problem with this method the more I think about it. Works fine for 3 elements / variables, but what if there's say 5, whereas 3 of them = 100 and the other 2 = 50 -- which ones do we report as being the same? As is the code will return a value of 5.

    The solution is limited but not flawed ...

    Trent Jackson
    Last edited by T.Jackson; - 9th June 2008 at 13:16.

Similar Threads

  1. Alternative for 'printf'
    By Sach_1979 in forum General
    Replies: 1
    Last Post: - 25th September 2009, 01:02
  2. Pulsin alternative
    By sbobowski in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 4th October 2008, 09:21
  3. Alternative to the H44780 lcd controler
    By Sphere in forum Off Topic
    Replies: 11
    Last Post: - 31st July 2008, 19:17
  4. alternative Pin for vref
    By ruijc in forum General
    Replies: 6
    Last Post: - 15th January 2008, 10:46
  5. Alternative power supply
    By The Master in forum Off Topic
    Replies: 2
    Last Post: - 20th November 2007, 13:38

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts