第十四周项目 阅读程序 2
来源:互联网 发布:禁止系统安装软件 编辑:程序博客网 时间:2024/05/17 01:32
/* *Copyright(c) 2016, 烟台大学计算机与控制工程学院 *All rights reserved. *文件名称:main.cpp *作 者:李德坤 *完成日期:2016年5月29日 *版本号:v1.0 * *问题描述:阅读程序 *输入描述:无 *输出描述:无*/#include <iostream>#include <vector>using namespace std;int main(){ vector<int> intList; vector<int>::iterator listIt; int i; intList.push_back(1); intList.push_back(5); intList.push_back(10); intList.push_back(15); cout<<"Line 1: List Elements: "; for(i=0; i<4; i++) cout<<intList[i]<<" "; cout<<endl; for(i=0; i<4; i++) intList[i] *=2; cout<<"Line 2: List Elements: "; for(listIt=intList.begin(); listIt != intList.end(); ++listIt) cout<<*listIt<<" "; cout<<endl; listIt=intList.begin(); ++listIt; ++listIt; intList.insert(listIt,8);//通过查阅c++手册得知,insert是在迭代器指定位置插入元素 cout<<"Line 3: List Elements: "; for(listIt = intList.begin(); listIt != intList.end(); ++listIt) cout<<*listIt<<" "; cout<<endl; return 0;}/*输出结果为:Line 1: List Elements: 1 5 10 15Line 2: List Elements: 2 10 20 30Line 3: List Elements: 2 10 8 20 30*/
0 0
- 第十四周项目 阅读程序 2
- 第十四周阅读程序2
- 第十四周阅读程序2
- 第十四周 阅读程序 2
- 第十四周阅读程序2
- 第十四周阅读程序-2
- 第十四周阅读程序2
- 第十四周阅读程序2
- 第十四周项目六 阅读程序(1、2、3)
- 第十四周上机实践项目1(2):阅读程序
- 第十四周项目六:阅读程序
- 第十四周项目6阅读程序
- 第十四周项目六阅读程序
- 第十四周项目6-阅读程序
- 第十四周项目六之阅读程序
- 第十四周项目六 阅读程序 (7)
- 第十四周项目六 阅读程序 (8)
- 第十四周项目六 阅读程序 (9)
- HDU 2478 Slides(n个矩形中n-1个矩形相交最大面积)
- kafka架构原理和安装部署
- 1019-S专题三
- CSS定义超链接四个状态的正确顺序L-V-H-A
- Leetcode 232. Implement Queue using Stacks
- 第十四周项目 阅读程序 2
- Gym 100917EExtreme Permutations(状压dp)
- 第十四周项目一(1) 阅读程序,解释程序运行得到的结果
- Logistic Regression
- 第十四周项目 阅读程序 3
- [sql2008错误问题] RegisteredServerException 异常
- Windows下Apache以FastCGI模式运行PHP
- 2016SDAU编程练习三1007
- 2016-5-29:实验室第四天