加载中…
个人资料
Lance
Lance
  • 博客等级:
  • 博客积分:0
  • 博客访问:1,108
  • 关注人气:27
  • 获赠金笔:0支
  • 赠出金笔:0支
  • 荣誉徽章:
博文
标签:

游戏

分类: C程序例子
#include <iostream>
#include <vector>

using std::cin;
using std::cout;
using std::endl;
using std::vector;

int main()
{
vector<int> ivec;
int ival;

cout << 'Enter some integers for vector(Ctrl + Z to end):' << endl;
while(cin >> ival)
{
ivec.push_back(ival);
}
if(ivec.empty())
{
cout << 'No element!' << endl;
}
else
{
cout << 'first element from subscript:' << ivec[0] << endl;
cout << 'first element from front(): ' << ivec.front() << endl;
cout << 'first element from begin(): ' << *ivec.begin() << endl;
cout << 'first element from at(): ' << ivec.at(0) << endl;
}

return 0;
}
  

新浪BLOG意见反馈留言板 欢迎批评指正

新浪简介 | About Sina | 广告服务 | 联系我们 | 招聘信息 | 网站律师 | SINA English | 产品答疑

新浪公司 版权所有