软题库 移动APP 扫码下载APP 随时随地移动学习 培训课程
当前位置:信管网 >> 在线考试中心 >> 信息系统项目管理师题库 >> 试题查看
试卷名称 2008年下半年程序员考试下午真题试题(案例分析)
考试中心《2008年下半年程序员考试下午真题试题(案例分析)》在线考试
试卷年份2008年下半年
试题题型【分析简答题】
试题内容

阅读以下说明和C++代码,将应填入 (n) 处的字句写在答题纸的对应栏内。
【说明】 
C++标准模板库中提供了vector模板类,可作为动态数组使用,并可容纳任意数据类型,其所属的命名空间为std。vector模板类的部分方法说明如下表所示:

【C++代码】 
#include <iostream>
#include <vector>
using namespace  (1) ;
typedef vector< (2) > INTVECTOR;
const int ARRAY_SIZE = 6;
void ShowVector(INTVECTOR &theVector);
int main(){
 INTVECTOR theVector;
 // 初始化theVector,将theVector的元素依次设置为0至5
 for (int cEachItem = 0; cEachItem < ARRAY_SIZE; cEachItem++)
theVector.push_back( (3) );
ShowVector(theVector);    // 依次输出theVector中的元素
theVector.erase(theVector.begin() + 3);  
ShowVector(theVector);
}
void ShowVector(INTVECTOR &theVector) {
 if (theVector.empty())  {
   cout << "theVector is empty." << endl;    return;
 }
   INTVECTOR::iterator (4) ;
   for(theIterator = theVector.begin(); theIterator != theVector.end(); theIterator++){
     cout << *theIterator; 
  if (theIterator != theVector.end()-1)    cout << ", ";
   }
     cout << endl;
}
该程序运行后的输出结果为:(5)   


相关试题

推荐文章
合作网站内容