for(i=n-1; i<=m;i++)
{
//agregar codigo para insertar en el sub arreglo.
}
#include <iostream>
using namespace std;
int* subLista(int n, int m, int arreglo[]){
int* arr = new int(m);
n--; //..Para ajustar el inicio.
for(int i = n; i < (n+m); i++)
arr[i-n] = arreglo[i];
return arr;
}
int main()
{
int arreglo[] = {10,8,20,25,30,9,2,1};
int n = 3, m = 4;
int* arr = subLista(n,m,arreglo);
//...Mostrar el resultado.
for(int j = 0; j < m ; j++)
cout << arr[j] << " ";
cout <<"\n";
return 0;
}
Lista L1=L.Sublista(3,4)... se obtiene L1={20,25,30,9}
// copy algorithm example
#include <iostream> // std::cout
#include <algorithm> // std::copy
#include <vector> // std::vector
int main () {
int myints[]={10,20,30,40,50,60,70};
std::vector<int> myvector (7);
std::copy ( myints, myints+7, myvector.begin() );
std::cout << "myvector contains:";
for (std::vector<int>::iterator it = myvector.begin(); it!=myvector.end(); ++it)
std::cout << ' ' << *it;
std::cout << '\n';
return 0;
}