- 587 名前:デフォルトの名無しさん mailto:sage [2009/04/04(土) 20:30:19 ]
- >>584
#include <iostream> #include <vector> #include <iterator> #include <algorithm> float power2(float x) { return x*x; } int main() { const int size = 10; float c = 0.1; std::vector<float> vec1(size), vec2(size); for(int i = 0; i < size; ++i){ vec1[i] = c; c += 1.1; } std::transform(vec1.begin(), vec1.end(), vec2.begin(), power2); std::copy(vec2.begin(), vec2.end(), std::ostream_iterator<float>(std::cout, ",")); return 0; }
|

|