please help (sequential search)

This is a discussion on please help (sequential search) within the C Programming forums, part of the General Programming Boards category; Ive brought an array into this function of 100 indexes. I need a way to search each cell with a ...

  1. #1
    Registered User
    Join Date
    Sep 2006
    Posts
    12

    please help (sequential search)

    Ive brought an array into this function of 100 indexes. I need a way to search each cell with a random number "randx"into the array, and count the number of successful searches. Nos is number of searches. Plaese help me out here, ive been working on this for a while, and im stuck.

    Code:
    #include "my.h"
    
    void searchNum(int Ar[ ], int* sch, int* suc, float* percent, float* tps, int lo, int range, int nos)
    {
    int randx;
    int i;
    
    for(i=0;i<nos;i++)
    {
                    randx=(((rand())%range)+lo);
    //I DONT KNOW WHAT TO PUT HERE
    
    }                       
    
    }

  2. #2
    Registered User
    Join Date
    Sep 2006
    Posts
    12
    This is what i have

    Code:
    for(i=0;i<nos;i++)
    {
            randx=(((rand())%range)+lo);
            count=0;
            for(j=0;j<100;j++)
            { 
                    count++;
    
    
                            if(Ar[j]==randx)
                    {       *suc++;
    
                    }
            }
            
            
    }

  3. #3
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,533
    > *suc++;
    Increments the pointer

    (*suc)++;
    Increments what the pointer points to.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Binary Search Trees Part III
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 10-02-2004, 03:00 PM
  2. Tutorial review
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 11
    Last Post: 03-22-2004, 08:40 PM
  3. Request for comments
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 01-02-2004, 09:33 AM
  4. Recursive sequential search
    By supaben34 in forum C++ Programming
    Replies: 2
    Last Post: 10-10-2002, 11:06 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21