#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
void PrintCube(int n)
{
cout << "The cube of " << n << " is " << n * n * n << endl;
}
int main(void)
{
const int VECTOR_SIZE = 8 ;
typedef vector<int > IntVector ;
typedef IntVector::iterator IntVectorIt;
IntVector Numbers(VECTOR_SIZE) ;
IntVectorIt start, end, it ;
int i ;
for (i = 0; i < VECTOR_SIZE; i++)
Numbers[i] = i + 1 ;
start = Numbers.begin() ;
end = Numbers.end() ;
for(it = start; it != end; it++)
cout << *it << " " ;
for_each(start, end, PrintCube);
}
|