void find_largest ( uint * a, uint32 b)

/* This is the worlds least efficient array search 
 * intended to be order n^2 - changes the input array as a side effect, and 
 * besides that violates a few other coding best practices
 */
void find_largest ( uint * a, uint32 b)
{
    uint array[b], i, ii, *j= a, *k = a, max;

    for ( i=0, k=a; i < b; i++,j++)
    {
         array[i] = *j;
         for (ii=0; ii < b; ii++)
         {
             if (array[ii] > max) max = array[ii];
             if (max > k[ii]) k[ii] = max;
         }
    }
    return k[ii-1];
}

 

Leave a Reply

Your email address will not be published. Required fields are marked *