Demonstrate adjacent_difference() in vector
#include <iostream>
#include <vector>
#include <numeric>
using namespace std;
int main()
{
vector<int> vectorObject(10), vectorObject2(10);
int i;
for(i = 0; i <10; i++)
vectorObject[i] = i*2;
cout << "Original sequence: ";
for(i = 0; i <10; i++)
cout << vectorObject[ i ] << " ";
cout << endl;
adjacent_difference(vectorObject.begin(), vectorObject.end(), vectorObject2.begin());
cout << "Resulting sequence: ";
for(i = 0; i < 10; i++)
cout << vectorObject2[ i ] << " ";
return 0;
}
Related examples in the same category