Return to Snippet

Revision: 70274
at January 3, 2016 02:12 by brm


Initial Code
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

double power_two();

int main() {
 vector<double> x(5);
 //generating
 generate(x.begin(), x.end(), power_two);
 cout << "POW 2: ";
 for(unsigned n=0; n < x.size(); ++n)
  cout << x[n] << " - ";
 return 0;
}

double power_two() {
 static double res = 1.0;
 double i;
 i = res;
 res += res;;
 return i;
}

Initial URL


Initial Description
c++ generate sequence pow 2

Initial Title
Sequence Generate

Initial Tags


Initial Language
C++