#include <iostream>
#include <valarray>
using namespace std;
int main()
{
valarray<int> v(10), result;
unsigned int i;
for(i=0; i<10; i++) v[i] = i;
cout << "Contents of v: ";
for(i=0; i<10; i++)
cout << v[i] << " ";
cout << endl;
result = v[slice(0,5,2)];
cout << "Contents of result: ";
for(i=0; i<result.size(); i++)
cout << result[i] << " ";
return 0;
}
|