#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int Fibonacci(void){
static int r;
static int f1 = 0;
static int f2 = 1;
r = f1 + f2;
f1 = f2;
f2 = r;
return f1;
}
int main(void){
const int VECTOR_SIZE = 15;
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 * i;
start = Numbers.begin();
end = Numbers.end();
for (it = start; it != end; it++)
cout << *it << " ";
generate_n(start + 5, Numbers.size() - 5, Fibonacci);
for (it = start; it != end; it++)
cout << *it << " ";
}
|