Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: A silly question about C

Author: Robert Hyatt

Date: 15:11:19 07/20/04

Go up one level in this thread


On July 20, 2004 at 18:09:47, Antonio Senatore wrote:

>
>Hi friends:
>
>I have an array of 100 elements (positive integers) and I need to know what is
>the highest value stored in the array. Does anyone know a way faster than
>
>max_value = 0;
>
>for (i=0; i &le= 99; i++) {
>       if (values[i] &ge max_value) max_value = values[i];
>}
>
>I work in C
>
>Many thanks in advance
>
>Antonio


Not unless you build the array at run-time.  Then every time you add an entry,
you can do the check at that point and just keep up with the largest entry ever
added.



This page took 0 seconds to execute

Last modified: Thu, 15 Apr 21 08:11:13 -0700

Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.