STL Vector使用例程

    xiaoxiao2022-07-02  117

    #include <stdio.h> #include <iostream> #include <vector> #include <algorithm> using namespace std; int main(){ vector <int> a; for(int i = 0; i < 10; i++) { a.push_back(i); } //反序 reverse(a.begin(),a.end()); for (int i = 0; i < a.size(); i++){ printf("%d\n",a[i]); } //正序 sort(a.begin(),a.end()); for (vector<int>::iterator it=a.begin(); it < a.end();it++){ printf("%d\n",*it); } return 1; }

    关于vector详细使用说明,详见http://www.cplusplus.com/reference/vector/vector/vector/

    最新回复(0)