使用STL库sort函数对vector进行排序,vector的内容为对象的指针,而不是对象. 代码如下 #include <stdio.h> #include <vector> #include <algorithm> using namespace std; class Elm { public: int m_iSortProof; private: int __m_iValue; static int __m_iCnt; public: Elm(); int get…
嗯... 不得不说c++中的STL库是一个神奇的东西 可以使你的代码显得更加简洁.... 今天就只讲STL中的三个鬼畜: max min swap 具体操作见代码!!! #include<cstdio> #include<algorithm>//此头文件包含了有关于算法的一些东西 using namespace std; int main() { //调用STL中的鬼畜 max(,);//只支持两个数,找出两个数中较大的一个数 min…
step1: #include <iostream> #include <vector> #include <string> using namespace std; main() { vector<string> SS; SS.push_back("The number is 10"); SS.push_back("The number is 20"); SS.push_back("The number i…
STL = Standard Template Library,标准模板库,惠普实验室开发的一系列软件的统称.它是由Alexander Stepanov.Meng Lee和David R Musser在惠普实验室工作时所开发出来的.这可能是一个历史上最令人兴奋的工具的最无聊的术语.从根本上说,STL是一些“容器”的集合,这些“容器”有list,vector,set,map等,STL也是算法和其他一些组件的集合.这里的“容器”和算法的集合指的是世界上很多聪明人很多年的杰作.STL的目的是标准化…