// FILE: SameArra.cpp // COMPARES TWO DOUBLE ARRAYS FOR EQUALITY BY COMPARING // CORRESPONDING ELEMENTS bool same_array (const apvector & a, // IN: double arrays to be compared const apvector & b, const int size) // IN: size of the arrays // Pre: a[i] and b[i] (0 <= i <= size-1) are assigned // values. // Post: Returns true if a[i] == b[i] for all i in range // 0 through size - 1; otherwise, returns false. { // Local data ... int i; // loop control variable and array subscript i = 0; while ((i < size-1) && (a[i] == b[i])) i++; return (a[i] == b[i]); // define result } // end same_array