vector模板类的用法
来源:互联网 发布:xbox one国行解锁 知乎 编辑:程序博客网 时间:2024/06/03 20:43
//vector1.cpp -- introducing the vector template#include <iostream>#include <string>#include <vector>const int NUM = 5;int main(){using std::vector; using std::string;using std::cin;using std::cout;using std::endl;vector<int> ratings(NUM); //将vector模板类实例化为存储5个int元素的类对象 vector<string> titles(NUM); //将vector模板类实例化为存储5个string元素的类对象cout << "You will do exactly as you told, you will enter\n" << NUM << "book titles and your ratings (0-10).\n";int i;for(i = 0; i < NUM; i++){cout << "Enter title " << i+1 << ": ";getline(cin, titles[i]);cout << "Enter your rating(0—10): ";cin >> ratings[i];cin.get();}cout << "Thank you, you entered the following:\n"<< "Rating\tBook\n";for(i = 0; i < NUM; i++){cout << ratings[i] << "\t" << titles[i] << endl;}cin.get();}
运行效果如图:
0 0
- vector模板类的用法
- vector模板的用法
- Vector类的用法
- Vector类的用法
- vector模板用法C++ std
- vector模板用法C++ std
- 精通标准模板库STL的向量Vector用法
- stl模板中vector的用法以及其功能
- 精通标准模板库STL的向量Vector用法
- vector模板类的成员函数
- vector模板类的C++实现
- 有关模板类----实现Vector的类模板
- c++vector模板类
- c++vector模板类
- vector模板类
- 类模板vector入门
- vector模板类
- vector模板类
- javascript数组元素的添加、删除与插入以及参数数组的使用
- 树型选择排序
- Objective-C 异步任务
- 生成格雷码(Gray Code)
- 关于错误 at::0 can't find referenced pointcut *****
- vector模板类的用法
- codeForces 373B
- CAM350软件使用说明----PADS相关
- IOS页面之间通过委托(协议)传值
- HEVC参考代码HM10.0的使用
- 什么是矩阵的范数
- JS跨域及Ajax实现
- bzoj2190仪仗队题解
- Ubuntu下无线网卡无法搜索信号