void NonContiguousIncreSubSeq(int *a,int n){ int b[100],m=0,index=a[0],c[100],p=0; memset(b, 0, 100); memset(c, 0, 100);//initialize and set values for arrays for (int i = 0; i < n - 1; i++) { b[m++] = a[i];//assign the initial value to the array index = a[i];//variable comparison initial for (int j = i + 1; j < n; j++) { if (a[j] > index) { b[m++] = a[j]; index = a[j]; } } if (m > p) { memcpy(c, b, m * sizeof(b[0]));//If the temporary array is longer than the max array, // assign the value of the temporary array to the max array p = m; } m = 0;//reset temporary array } for (int i = 0; i < p; i++) cout << c[i] << "\t";//export result }