/***********************
编写程序获取 vector 容器的第一个元素。分别使用下标
操作符、front 函数以及 begin 函数实现该功能,并提
供空的 vector 容器测试你的程序
***********************/
#include <iostream>
#include <vector>
using namespace std;
int main(void)
{
vector<int> vec;
int value;
while(cin >> value)
{
if(value == 999)
break;
vec.push_back(value);
}
vector<int>::iterator it = vec.begin();
cout << "vector is : ";
for(;it != vec.end(); it++)
{
cout << *it << " ";
}
cout << endl;
cout << "vector vec[0] " << vec[0] << endl;
cout << "vector front " << vec.front() << endl;
cout << "vector begin " << *vec.begin() << endl;
return 0;
}