?? 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 + -