<Stdlib. h> <. h> Judge (* a, len, Ascending =; Ascending = a []> a []? : * CopyA = (*) malloc () *, () * icount = (icount =; icount <len; icount ++ = x-I = len -, j = (I >=& & j <(a [I]>: j ++;: I --;: (a [I] =: I --;;: j ++;: a [] = {, len = x =: printf (, x);: printf (, x );:View Code
Judge (* a, len, begin = end = len-order =; (a [] <a [len-= (begin <(a [begin] + a [end]> (order = -- ++ (a [begin] + [end] = (order = + + --View Code
Judge (* a, len, begin = end = len-order =; (a [] <a [len-= (order = (begin <(a [begin] + a [end]> -- (a [begin] + a [end] ==++ (begin <(a [begin] + a [end]> ++ (a [begin] + a [end] = --View Code
: j++; ; : i--; ; :
: i--; ; : j++; ; :
Ascending = a[] > a[] ? : ;
memset(CopyA, , () * len);
(order == -- ++begin;
(order == ++ --end;
(a[] < a[len - = =
order = ;
(a[] > a[len - =
order = a[] > a[len - ];
(order == (begin <(a[begin] + a[end] >-- (a[begin] + a[end] == ++(begin <(a[begin] + a[end] >++ (a[begin] + a[end] == --
# Include <stdio. h> # include <stdbool. h> # define X 31 bool judge (int [], size_t, int); int main (void) {int test [] = {5, 10, 59 }; // {59,41, 5}; printf ("% d % s exist! \ N ", X, judge (test, sizeof test/sizeof * test, X )? "": "No"); return 0;} bool judge (int a [], size_t n, int x) {if (n <2u) return false; if (x = a [0] + a [n-1]) return true; if (x> a [0] + a [n-1]) ^ (a [0]> a [n-1]) return judge (a + 1, n-1, x); return judge (a, n-1, x );}
bool judge( int a[] , size_t n , int x ) { while ( n > 1u ) { if ( x == a[0] + a[n-1] ) return true ; if ( (x > a[0] + a[n-1]) ^ ( a[0] > a[n-1]) ) a ++ ; n -- ; } return false ; }