练习10.6

yuzuki_n / 2023-07-19 / 原文

用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;
    }
}