编程语言
首页 > 编程语言> > C++-std::iota

C++-std::iota

作者:互联网

1、功能

用一个从value递增的数列给[first, last)的容器赋值

2、实例

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

int main()
{
    std::vector<int> nums(10);

    for (int i : nums) {
        std::cout << i << "\t";
    }
    std::cout << std::endl;

    std::iota(nums.begin(), nums.end(), 5); // fill nums with 5, 6, 7, 8...

    for (int i : nums) {
        std::cout << i << "\t";
    }
    std::cout << std::endl;

    system("pause");
    return 0;
}

打印:

0       0       0       0       0       0       0       0       0       0
5       6       7       8       9       10      11      12      13      14

参考:https://www.jianshu.com/p/ffdb4c681392

标签:std,10,www,nums,int,C++,include,iota
来源: https://www.cnblogs.com/judes/p/16330428.html