今天使用这个算法来给一个数组赋值,所以把它的使用过程记录下来:

fill_n函数的作用是:给你一个起始点,然后再给你一个数值count和val。把从起始点开始依次赋予count个元素val的值。 
注意: 不能在没有元素的空容器上调用fill_n函数

例题:给你n个数,然后输入一些操作:start,count,paint。表示从start开始连续填充count个数字,paint为填充的数值。

// ConsoleApplication2.cpp : 定义控制台应用程序的入口点。
//

#include "stdafx.h"

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

int main()
{
	vector<int> myvector(8, 10);        // myvector: 10 10 10 10 10 10 10 10

	fill_n(myvector.begin(), 4, 20);     // myvector: 20 20 20 20 10 10 10 10
	fill_n(myvector.begin() + 3, 3, 33);   // myvector: 20 20 20 33 33 33 10 10

	cout << "myvector contains:";
	for (auto it : myvector)
	{
		cout << " " << it;
	}

	cout << endl;

	cin.get();

	return 0;
}

激情只能点燃梦想,习惯才能成就理想

1. RPG游戏从入门到精通


2. WiX安装工具的使用

3. 俄罗斯方块游戏开发
http://edu.csdn.net/course/detail/51104. boost库入门基础
http://edu.csdn.net/course/detail/50295.Arduino入门基础
http://edu.csdn.net/course/detail/49316.Unity5.x游戏基础入门
http://edu.csdn.net/course/detail/48107. TensorFlow API攻略
http://edu.csdn.net/course/detail/44958. TensorFlow入门基本教程
http://edu.csdn.net/course/detail/43699. C++标准模板库从入门到精通 
http://edu.csdn.net/course/detail/332410.跟老菜鸟学C++
http://edu.csdn.net/course/detail/290111. 跟老菜鸟学python
http://edu.csdn.net/course/detail/259212. 在VC2015里学会使用tinyxml库
http://edu.csdn.net/course/detail/259013. 在Windows下SVN的版本管理与实战 
http://edu.csdn.net/course/detail/257914.Visual Studio 2015开发C++程序的基本使用 
http://edu.csdn.net/course/detail/257015.在VC2015里使用protobuf协议
http://edu.csdn.net/course/detail/258216.在VC2015里学会使用MySQL数据库
http://edu.csdn.net/course/detail/2672

最新文章

  1. 【原】iOS学习之UITabBar的隐藏
  2. 让自己也能使用Canvas
  3. MySQL 5.5安装记录
  4. baiduMap
  5. 实用js代码大全
  6. Bootstrap滚动监听
  7. Linux 下 Shell 命令的分类及用法
  8. requirejs
  9. Linux常用命令_(磁盘管理)
  10. WebApiThrottle限流框架
  11. NodeJS - Express 3.0下ejs模板使用 partial展现 片段视图
  12. [转]NHibernate之旅(13):初探立即加载机制
  13. jQuery对checkbox的各种操作
  14. java提高篇(十四)-----关键字final
  15. HDU 2177 取(2堆)石子游戏 (威佐夫博弈)
  16. 查看主机DNSserver
  17. jquery自定义进度条与h5原生进度条
  18. EMMET 的HTM自动生成
  19. vChart
  20. mysql----------mysql5.7如何配置主从数据库

热门文章

  1. 20145322《Java程序设计》第4次实验报告
  2. 快用Visual Studio(三)- 代码重构
  3. 深度学习:Keras入门(一)之基础篇【转】
  4. Scrapy 分布式数据采集方案
  5. 建站有很多技术,如 HTML、HTML5、XHTML、CSS、SQL、JavaScript、PHP、http://ASP.NET、Web Services、浏览器脚本、服务器脚本等。它们的区别是什么?新手一点不懂,想理清所有这些技术之间的关系和应用范围。
  6. python sklearn.cross_validation 模块导入失败
  7. spring mvc 之初体验
  8. dp_c_区间dp_g
  9. JavaScript高级程序设计-读书笔记(1)
  10. Java里\r \n \t