#include
using namespace std;
// 常用算术生成算法
#include
#include //accumulate 的调用头文件
void test01()
{
vector<int>v;
for (int i = 0; i <= 100; i++)
{
v.push_back(i);
}
int total = accumulate(v.begin(), v.end(), 10000); //10000 是初始值
cout << "Total = " << total << endl;
}
int main()
{
test01();
cout << "------------------------" << endl;
//test02();
//cout << "------------------------" << endl << endl;
//test03();
//**************************************
system("pause");
return 0;
}
#include
using namespace std;
// 常用算术生成算法 fill
#include
#include //fill 的头文件
#include //for_each 的头文件
void myPrint(int val)
{
cout << val << " ";
}
void test01()
{
vector<int>v;
v.resize(10);
cout << "填充前:" << endl;
for_each(v.begin(), v.end(), myPrint);
cout << endl;
fill(v.begin(), v.end(), 100);
cout << "填充后:" << endl;
for_each(v.begin(), v.end(), myPrint);
cout << endl;
}
int main()
{
test01();
cout << "------------------------" << endl;
//test02();
//cout << "------------------------" << endl << endl;
//test03();
//**************************************
system("pause");
return 0;
}