算数生成算法fill填充

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

class Print
{
public:
   void operator()(int i)
   {
      cout << i << endl;
   }
};

int main()
{
   vector<int> v;
   v.resize(10);

   fill(v.begin(), v.end(), 10);
   for_each(v.begin(), v.end(), Print());
   
   return 0;
}
$ ./a.out 
10
10
10
10
10
10
10
10
10
10
posted @ 2022-07-31 16:46  thomas_blog  阅读(16)  评论(0编辑  收藏  举报