📄 stlvectortest.cpp
字号:
// 这是使用应用程序向导生成的 VC++
// 应用程序项目的主项目文件。
#include "stdafx.h"
#include <vector>
#include <list>
#include <algorithm>
#using <mscorlib.dll>
#include <tchar.h>
#include <iostream>
using std::cout;
using std::endl;
using std::cin;
//using namespace System;
template < class T>
void printVec(const std::vector< T> &vec)
{
std::vector<T>::const_iterator p1;
for(p1=vec.begin();p1!=vec.end();p1++)
{
cout<<*p1<<" ";
}
cout<<endl;
}
template < class T>
void rePrintVec( const std::vector<T> &vec)
{
std::vector<int>::const_reverse_iterator p2;
for(p2=vec.rbegin();p2!=vec.rend();p2++)
{
cout<<*p2<<" ";
}
cout<<endl;
}
// 这是此应用程序的入口点
int _tmain(void)
{
// TODO: 请用您自己的代码替换下面的示例代码。
const int SIZE=6;
int a[SIZE]={1,2,3,4,5,6};
std::vector<int> v;
cout<<"the v.size is:"<<v.size()<<endl;
v.push_back(2);
v.push_back(3);
v.push_back(4);
v.push_back(5);
cout<<"the v.size is:"<<v.size();
cout<<"the v.capacity is:"<<v.capacity();
printVec(v);
rePrintVec(v);
std::vector<int >::iterator p2;
for(p2=v.begin();p2!=v.end();p2++)
{
cout<<"the p2[i]is:"<<*p2<<endl;
}
//std::vector<int>::reverse_iterator p2;
std::list<>
int x=0;
cin>>x;
// Console::WriteLine(S"Hello World");
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -