![](https://img-blog.csdnimg.cn/20201014180756928.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
C/C++
文章平均质量分 70
prosoul
这个作者很懒,什么都没留下…
展开
-
C++ primer 习题8.3
#include#includeusing namespace std;std::istream &get(std::istream &in){ int ival; while(in >> ival,!in.eof()){ if(in.bad()) throw std::runtime_error("IO system corrupted"); if(in.fail())原创 2013-08-19 13:49:34 · 677 阅读 · 0 评论 -
X86-64寄存器和栈帧
注明:该博客转载自淘宝搜索技术博客,作者:jiye http://www.searchtb.com/2013/03/x86-64_register_and_function_frame.html 概要说到x86-64,总不免要说说AMD的牛逼,x86-64是x86系列中集大成者,继承了向后兼容的转载 2015-05-08 19:54:01 · 906 阅读 · 0 评论 -
最大子序列和的四种解法
#include#includeusing namespace std;/*** Cubic maximum contiguous subsequence sum algorithm.*/int maxSubSum1(const vector & a){ int maxSum = 0; for(int i = 0; i < a.size();i++) for(int j原创 2015-03-12 15:25:32 · 522 阅读 · 0 评论 -
在遍历中使用 iterator/reverse_iterator 进行 Erase 的用法
本文转载自 罗朝晖的博客 http://blog.csdn.net/kesalin/article/details/24265303众所周知,在使用迭代器遍历 STL 容器时,需要特别留意是否在循环中修改了迭代器而导致迭代器失效的情形。下面我来总结一下在对各种容器进行正向和反向遍历过程中删除元素时,正确更新迭代器的用法。本文源码:https://code.csdn.net/snippe转载 2015-03-26 19:11:54 · 470 阅读 · 0 评论 -
快速排序
在看算法导论的第七章,介绍的是快速排序。快速排序使用分治策略来把待排序对象分成两个子对象,再对两个子对象进行递归,进而合并得到正确的排序结果#includeusing namespace std;void Swap(int *A, int i, int j){ int temp; temp = A[i]; A[i] = A[j]; A[j] = temp;}int P原创 2013-10-06 14:09:02 · 493 阅读 · 0 评论 -
C++Primer习题10.9
#include#includeusing namespace std;int main(){ map word_count; string word; while(cin >> word) ++word_count[word]; map::iterator map_it =word_count.begin(); while(map_原创 2013-08-28 10:23:11 · 544 阅读 · 0 评论 -
C++Primer10.1
#include#include#include#includeusing namespace std;int main(){ vector > pvec; pair p1; string str; int value; while(cin >> str >> value) { p1 = make_pair(str,v原创 2013-08-27 14:03:42 · 578 阅读 · 0 评论 -
C++Primer 习题9.39
#include#include#includeusing namespace std;int main(){ string line1 = "We were her pride of 10 she named us:"; string line2 = "Benjamin, Phoenix, the Prodigal"; string line3 = "and perspicaci原创 2013-08-26 13:38:44 · 617 阅读 · 0 评论 -
C++Primer习题9.40
#include#includeusing namespace std;/*//方法一: string greet(string form, string lastname, string title, string::size_type pos, int length){ form.replace(8,6,lastname); form.replace(5,2,title.su原创 2013-08-26 14:54:55 · 717 阅读 · 0 评论 -
C++Primer 习题9.38
#include#includeusing namespace std;int main(){ string numbers("0123456789"); string chars("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"); string str("ab2c3d7R4E6"); string::size_type原创 2013-08-26 10:42:28 · 654 阅读 · 0 评论 -
C++Primer习题9.26
#include#include#includeusing namespace std;int main(){ int ia[] = { 0,1,1,2,3,5,8,13,21,55,89 }; vector ivec(ia,ia+11); list ilist(ia,ia+11); for(list::iterator it = ilist.begin(); it原创 2013-08-23 16:41:01 · 582 阅读 · 0 评论 -
C++ primer 习题9.18
#include#include#includeusing namespace std;int main(){ list ilist; deque ideque1,ideque2; int ival[] ={ 0,1,2,3,4,5,6,7,8,9,10 }; ilist.insert(ilist.begin(),ival,ival + 10); list::ite原创 2013-08-23 14:12:56 · 663 阅读 · 0 评论