c++ stl algorithm: std::fill, std::fill_n

时间:2023-03-09 03:16:04
c++ stl algorithm: std::fill, std::fill_n

std::fill

在[first, last)范围内填充值

#include <iostream>
#include <vector>
#include <algorithm>
int main()
{
std::vector<int> v;
v.resize();
std::fill(v.begin(), v.end(), );
return ;
}

std::fill_n

在[fist, fist + count)范围内填充值

#include <iostream>
#include <vector>
#include <algorithm>
int main()
{
std::vector<int> v;
v.resize();
std::fill_n(v.begin(), , );
std::fill_n(v.begin() + , , );
return ;
}