**fig7_13.txt** /* 1*/ template /* 2*/ Etype & /* 3*/ Median3( Etype A[ ], /* 4*/ const unsigned int Left, const unsigned int Right ) /* 5*/ { /* 6*/ unsigned int Center = ( Left + Right ) /2; /* 7*/ if( A[ Left ] > A[ Center ] ) /* 8*/ Swap( A[ Left ], A[ Center ] ); /* 9*/ if( A[ Left ] > A[ Right ] ) /*10*/ Swap( A[ Left ], A[ Right ] ); /*11*/ if( A[ Center ] > A[ Right ] ) /*12*/ Swap( A[ Center ], A[ Right ] ); /*13*/ // Invariant: A[ Left ] <= A[ Center ] <= A[ Right ]. /*14*/ // Now hide and return pivot. /*15*/ Swap( A[ Center ], A[ Right - 1 ] ); /*16*/ return A[ Right - 1 ]; /*17*/ }