/ Published in: C++
c++ generate sequence pow 2
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
#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; }