/ * In a sequence consisting of N numbers, the longest monotonous junction sequence is found. The subsequence is continuous * /
#include
template Template Template / / Determine the value of Tempsubsize INT TEMPSUBSIZE = 1; INT POINTER = SIZE >> 1; // Pointer pointing the middle of the source sequence (Pointer 1 Pointer = size >> 1; // Indicator Refers to the middle of the source sequence (Pointer> 0 && Arr [Pointer-1] IF (Tempsubsize> Subsize) {// If this subsequence is longer than previously found subsets, updates Subsize Subsize = Tempsubsize; Arrcopy INT * LEFT = 0; // Left is the left portion INT LEFTSIZE = Pointer; if (Leftsize> subsize) {Arrcopy INT * Right = 0; // Right is the right part of the single-tuning propriety sequence in the middle of the source sequence, INT RIGHTSIZE = Size - Pointer - Subsize; IF (Rightsize> Subsize) {Arrcopy IF (Pointer> Subsize) {// Calculate the longest single-tuning probing gem sequence on the left part GetMaxIncSubarr (LEFT, LEFTSIZE, SUB, SUBSIZE); Delete [] LEFT;} if (Rightsize> Subsize) {// Calculated on the right part The longest monotonized junction sequence GetMaxIncSubarr (Right, Rightsize, Sub, Subsize); delete [] right;}} INT Main (int Argc, char * argv []) {int Arr [] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; int size = sizeof (arr) / sizeof int * sub = 0; int subsize = 0; getMaxincsubarr cin.get (); return 0;