CicyIris

2010年10月28日

单链表归并

摘要: #include<iostream>using namespace std;typedef struct linknode{int data;struct linknode *next;}nodetype;nodetype *hebing(nodetype *h1,nodetype *h2){nodetype *p1=h1,*p2=h2,*t1,*t2;nodetype *head=(... 阅读全文

posted @ 2010-10-28 11:51 CicyIris 阅读(201) 评论(0) 推荐(0)

2010年10月26日

避免存储end操作返回的迭代器

摘要: 在vector或deque容器中添加元素时,可能导致某些或全部迭代器失效。下边是一个例子: vector<int>::iterator first=v.begin(), last=v.end();while(first!=last){first=v.insert(first,42);++first;} 很多情况下,上边的代码会导致死循环。为了避免存储end迭代器,需要在每次插入新元素后... 阅读全文

posted @ 2010-10-26 14:24 CicyIris 阅读(203) 评论(0) 推荐(0)

2010年10月11日

数组和指针

摘要: 一、int *a,b,c;此句中只有a是指针变量,其他为int型变量。如果需要将三者都定义为指针变量,则应该写为:int *a;int *b;int *c;二、C++中函数传递方式为3种:按值传递、指针传递、引用传递。按值传递中,被传递的参数值在函数体内改变时,调用主题的原始数值不会发生改变。例如:#include<iostream>#include<cstdlib>usi... 阅读全文

posted @ 2010-10-11 23:49 CicyIris 阅读(166) 评论(0) 推荐(0)

导航