随笔分类 -  C++ STL

摘要:1 /*关于C++ STL中deque的学习*/ 2 #include 3 #include 4 #include 5 6 using namespace std; 7 void print(deque d); 8 void rprint(deque d); 9 int main() 10 { 11 deque dq; 12 dq.push_back(1);... 阅读全文
posted @ 2018-06-03 17:10 Reqaw 阅读(1057) 评论(0) 推荐(0)
摘要:问题描述 AOA非常喜欢阅读莎士比亚的诗,莎士比亚的诗中有种无形的魅力吸引着他!他认为莎士比亚的诗中之所以些的如此传神,应该是他的构词非常好!所以AOA想知道,在莎士比亚的书中,每个单词出现的频率各是多少? 输入 输入一个单词列表,每行一个单词,每个单词的长度不会超过30,单词的种类不会超过1000 阅读全文
posted @ 2018-04-03 19:16 Reqaw 阅读(335) 评论(0) 推荐(0)
摘要:Description One measure of ``unsortedness'' in a sequence is the number of pairs of entries that are out of order with respect to each other. For inst 阅读全文
posted @ 2018-04-03 18:07 Reqaw 阅读(285) 评论(0) 推荐(0)
摘要:Description Businesses like to have memorable telephone numbers. One way to make a telephone number memorable is to have it spell a memorable word or 阅读全文
posted @ 2018-04-03 11:52 Reqaw 阅读(161) 评论(0) 推荐(0)
摘要:题目链接: http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=2724 题目描述: Message queue is the basic fundamental of windows system. For each proce 阅读全文
posted @ 2018-03-11 12:00 Reqaw 阅读(220) 评论(0) 推荐(0)
摘要:题目链接: http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=2723 题目描述: Prime Number Definition An integer greater than one is called a prime nu 阅读全文
posted @ 2018-03-11 11:58 Reqaw 阅读(344) 评论(0) 推荐(0)
摘要:题目链接: http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=2104 题目描述: Contest time again! How excited it is to see balloons floating around. B 阅读全文
posted @ 2018-03-11 11:51 Reqaw 阅读(247) 评论(0) 推荐(0)
摘要:题目链接: http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=2060 题目描述: There are another kind of Fibonacci numbers: F(0) = 7, F(1) = 11, F(n) = 阅读全文
posted @ 2018-03-11 11:48 Reqaw 阅读(242) 评论(0) 推荐(0)
摘要:题目链接: http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=1760 题目描述: As part of an arithmetic competency program, your students will be given 阅读全文
posted @ 2018-03-11 11:43 Reqaw 阅读(235) 评论(0) 推荐(0)
摘要:题目连接: acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=1109 题目描述: We all know that FatMouse doesn't speak English. But now he has to be prepared 阅读全文
posted @ 2018-03-11 11:34 Reqaw 阅读(175) 评论(0) 推荐(0)
摘要:特别注意,由于list对象的结点并不要求在一段连续的内存中,所以,对于迭代器,只能通过++或者--的操作将迭代器移动到后继或者前驱结点元素处。而不能对迭代器进行+n或者-n的操作,这点与vector等不同的地方。 1 /*关于C++STL中的list双向链表容器的学习。*/ 2 #include < 阅读全文
posted @ 2018-03-08 18:01 Reqaw 阅读(776) 评论(0) 推荐(0)
摘要:multimap和map的不同之处在于前者允许重复键值的元素出现。 1 /*关于C++STL中mulitmap的学习,与map不同的是,multimap允许插入重复键值的元素*/ 2 #include <map> 3 #include <string> 4 #include <iostream> 5 阅读全文
posted @ 2018-03-08 17:59 Reqaw 阅读(283) 评论(0) 推荐(0)
摘要:stack堆栈是一个后进先出的线性表,插入和删除元素都在表的一端进行。 stack堆栈的使用方法: 采用push()方法将元素入栈; 采用pop()方法将元素出栈; 采用top()方法访问栈顶元素; 采用empty()方法判断堆栈是否为空; 采用size()方法返回堆栈中有几个元素。 queue队列 阅读全文
posted @ 2018-03-08 17:57 Reqaw 阅读(579) 评论(0) 推荐(0)
摘要:map映照容器的数据元素是由一个键值和一个映照数据组成的,键值和映照数据之间具有一一对应的关系。map与set集合容器一样,不允许插入的元素的键值重复。 /*关于C++STL中map映照容器的学习,看别人的代码一百遍,不如自己动手写一遍。*/ #include <map> #include <str 阅读全文
posted @ 2018-03-05 20:28 Reqaw 阅读(418) 评论(0) 推荐(0)
摘要:关于C++STL中multiset集合容器的学习,看别人的代码一百遍,不如自己动手写一遍。 multiset多重集合容器和set集合容器的使用方法大多相同,不同的是multiset多重集合容器允许重复的元素键值插入。 1 #include <set> 2 #include <string> 3 #i 阅读全文
posted @ 2018-03-05 16:52 Reqaw 阅读(1696) 评论(0) 推荐(0)
摘要:关于C++STL中set集合容器的学习,看别人的代码一百遍,不如自己动手写一遍。 构造set集合容器的目的是为了去重+排序+快速搜索。由于set集合容器实现了红黑树多的平衡二叉检索树的数据结构,在插入或者删除是,均能自动调整二叉树,使得二叉树始终保持新的平衡。除set外,multiset,map,m 阅读全文
posted @ 2018-03-05 13:42 Reqaw 阅读(3726) 评论(0) 推荐(2)
摘要:C语言只提供了一个char类型用来处理字符,而对于字符串,只能通过字符串数组来处理,而C++STL提供了string基本字符序列容器来处理字符串,可以将其理解为字符串类,它提供了添加,删除,替换、查找和比较等丰富、简洁的方法。 下面是在编写代码是的具体应用。 1 //关于C++ STL string 阅读全文
posted @ 2018-03-04 17:31 Reqaw 阅读(446) 评论(0) 推荐(0)
摘要:关于STL中vector容器的学习,编译运行后边看代码,边看执行结果效果更佳,还是想说看别人的代码一百遍,不如自己动手写一遍。 vector向量容器不但能像数组一样对元素进行随机访问,还能随时在尾部插入元素,简单而高效,能够完全替代数组。 vector最大的亮点在于具有内存自动管理的功能,插入和删除 阅读全文
posted @ 2018-03-04 10:12 Reqaw 阅读(8804) 评论(6) 推荐(1)