随笔分类 -  STL

摘要:数组去重并排序思路:先去重后排序或者先排序后去重可以使用STL来求,set内部是有序的,list内部不是有序的。样例:输入:46 3 3 9输入3 6 9 1 #include 2 #include 3 #include 4 #include 5 using namespace std; 6... 阅读全文
posted @ 2015-09-20 18:34 天天AC 阅读(283) 评论(0) 推荐(0)
摘要:#include 算法常用版本描述返回Typestd::find()find(_InIt _Fisrt,_InIt _Last, _Ty& _Val); 从两个迭代器指定的范围中查找指定值 引用被查找的值的iterator或end() std::find_if() find_if(_In... 阅读全文
posted @ 2015-05-16 11:26 天天AC 阅读(710) 评论(0) 推荐(0)
摘要:1 # include 2 # include 3 # include 4 using namespace std; 5 int main(int argc,const char *argv[]) 6 { 7 /*-----------------------------*/ 8 //插入元素 9 //dequed; 10 //d.push_back(1); 11 //d.push_back(2); 12 //d.push_back(3); 13 //coutd; 18 //d.push_back(1); 19... 阅读全文
posted @ 2013-12-06 20:53 天天AC 阅读(137) 评论(0) 推荐(0)
摘要:1 # include 2 # include 3 # include 4 using namespace std; 5 int main(int argc,const char *argv[]) 6 { 7 /*-----------------------------------*/ 8 //multimap对象创建,元素插入 9 //multimap m;10 // m.insert(pair("Jack",300.5));11 // m.insert(pair("Kity",200));12 //m.insert(pair("kity& 阅读全文
posted @ 2013-12-06 20:51 天天AC 阅读(159) 评论(0) 推荐(0)
摘要:1 # include 2 # include 3 # include 4 using namespace std; 5 int main(int argc,const char *argv[]) 6 { 7 /*-------------------------------------------*/ 8 //multiset中插入数据 9 //multisetms;10 //ms.insert("abc");11 // ms.insert("123");12 //ms.insert("111");13 //ms.insert(&q 阅读全文
posted @ 2013-12-05 18:51 天天AC 阅读(161) 评论(0) 推荐(0)
摘要:1 # include 2 # include 3 # include 4 using namespace std; 5 struct myComp 6 { 7 bool operator()(const int &a, const int &b) 8 { 9 if(a!=b) 10 { 11 return a>b; 12 } 13 else 14 { 15 return a>b; 16 } 17 } 18 ... 阅读全文
posted @ 2013-12-05 18:49 天天AC 阅读(205) 评论(0) 推荐(0)
摘要:1 # include 2 # include 3 # include 4 using namespace std; 5 struct myComp 6 { 7 bool operator()(const int &a,const int &b) 8 { 9 if(a!=b) 10 return a>b; 11 else 12 return as; 29 //s.insert(8); 30 //s.insert(1); 31 //s.insert(12);... 阅读全文
posted @ 2013-12-05 18:48 天天AC 阅读(163) 评论(0) 推荐(0)
摘要:1 # include 2 # include 3 # include 4 # include 5 # include 6 # include 7 using namespace std; 8 int main(int argc,const char *argv[]) 9 { 10 /*------------------------------------------*/ 11 //length 12 //string s; 13 //s = "abc123456"; 14 //cout 21 //string s; 22 ... 阅读全文
posted @ 2013-12-03 17:24 天天AC 阅读(218) 评论(0) 推荐(0)
摘要:1 # include 2 # include 3 # include 4 # include 5 using namespace std; 6 int main(int argc, const char * argv[]) 7 { 8 //vector容器的定义三种 9 //(1) vectorv 10 //(2) vectorv(3)用来存储3的double型的容器 11 //(3) vector(10,8.7)用来存储10个装有8.7的容器 12 13 //vectorv(3);//其中的3为元素的个数 14 /... 阅读全文
posted @ 2013-12-03 16:00 天天AC 阅读(206) 评论(0) 推荐(0)
摘要:头文件都是:#include<algorithm>qsort篇qsort(a,len,sizeof(type),mycmp)//注释a:待排序的数组地址len:待排序的数组的长度type:待排序的数组元素的类型mycmp:自定义的排序函数 1 /****************一维数组类比较函数************ 2 int mycmp(const void *a,const void *b) 3 { 4 return *(int *)a - *(int *)b; 5 } 6 //注 char、float、double型数组时 7 //只需将return中的int改成相应的类 阅读全文
posted @ 2013-04-19 17:01 天天AC 阅读(201) 评论(0) 推荐(0)