/**********************************************************************************/ /* */ /* C Programs from Chapter 1 of */ /* Data Structures, Algorithms and Software Principles in C */ /* by Thomas A. Standish */ /* */ /* Copyright (C) 1995, Addison-Wesley, Inc., all rights reserved */ /* */ /**********************************************************************************/ /**********************************************************************************/ | #define MaxIndex 100 | | int Find(int A[]) /* Find operates on integer arrays, A */ | { 5 | int j; /* j is an index variable used in the search */ | | for (j = 0; j= 0) && (i < MaxIndex)) { | ++i; | } | | return (i < MaxIndex) ? i : -1; 10 | } Program for Exercise 1 on page 21 /**********************************************************************************/ | int Find( int A[ ] ) | { | int i, result; | 5 | result = -1; | for (i = MaxIndex-1; i >= 0; --i) if (A[i] < 0) result = i; | return result; | } Program for Exercise 2 on page 21 /**********************************************************************************/