#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
void test01(void)
{
vector<int>temp;
temp.push_back(10);
temp.push_back(20);
temp.push_back(30);
temp.push_back(40);
temp.push_back(50);
vector<int>::iterator _begin = temp.begin();
vector<int>::iterator _end = temp.end();
while (_begin != _end)
{
cout << *_begin << endl;
_begin++;
}
}
void test02(void)
{
vector<int>temp;
temp.push_back(11);
temp.push_back(22);
temp.push_back(33);
temp.push_back(44);
temp.push_back(55);
for(vector<int>::iterator _begin = temp.begin();_begin != temp.end();_begin++)
cout << *_begin << endl;
}
void print(int num)
{
cout << num << endl;
}
void test03(void)
{
vector<int>temp;
temp.push_back(12);
temp.push_back(23);
temp.push_back(34);
temp.push_back(45);
temp.push_back(56);
for_each(temp.begin(), temp.end(), print);
}
int main()
{
test01();
test02();
test03();
return 0;
}
|