练习10.6

用std::fill_n把一个int序列填充为0

#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

int main(int argc, char* argv[])
{
    vector<int> v {1, 2, 3, 4, 5};
    std::fill_n(v.begin(), v.size(), 0);

    for (auto value : v)
    {
        cout << value << endl;
    }
}
posted @ 2023-07-18 22:58  yuzuki_n  阅读(9)  评论(0)    收藏  举报