- 博客(4)
- 收藏
- 关注
原创 链表反转
/* struct node { int data; struct node *pn; };*/ ph是一个带头节点的链表,现在我们用一个函数对它进行反转。即让头节点指向链表的尾部,让尾部依次向指向它的前一个节点。 void reversal(node *ph) { node *temp=ph;//因为我们传入的是头节点,头节点并不需要反转,但是需要把它的pn指向等会儿我们
2016-04-24 19:16:45 248
原创 宏定义,电脑不是人脑
我们先来看这样一段代码 #include #define M(x,y,z) x*y+z void main() { int a=1, b=2, c=3; printf("%d \n",M(a+b,b+c,c+a)); } 如果你的答案是19,那么恭喜你错了,你需要好好读一下这篇文章。 19是怎么来的呢,a+b=3,b+c=5,c+a=4;3*5+4
2016-04-10 14:10:04 397 1
原创 逗号运算符
首先我们来看一段代码 #include int main() { int x; int a=1,b=2,c=3; x=(a++,b++,c++); printf("%d",x); } 逗号运算符会取最右边的值,即x=c++; 运算得x=3; #include int main() { int x; int a=1,b=2,c=3; x=(a++,b++,b+
2016-04-10 13:57:29 340
原创 twoSum,利用双指针返回下标
利用双指针查找数组元素,并返回元素下标。 #include #include #include int comp(const void*a,const void*b)//用来做比较的函数。 { return *(int*)a-*(int*)b; } int* twoSum(int* nums,int numsSize,int target) {
2016-04-10 13:07:24 585
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人