当前位置: 首页 > news >正文

免费网站app源码WordPress博客系统安装

免费网站app源码,WordPress博客系统安装,营销平台建设,义乌网站建设公司代理2014-10-27 09:13:00更新你仔细研究一下我写的 testAsignPoint 和 testAsignPointAgain 函数就会明白为什么你的二级指针无效了。还是那句话#xff0c;你要记住#xff0c;指针就是一个变量#xff0c;存的是32位数据#xff0c;记住这个才能真正的理解指针。另外 pezy 说…2014-10-27 09:13:00更新你仔细研究一下我写的 testAsignPoint 和 testAsignPointAgain 函数就会明白为什么你的二级指针无效了。还是那句话你要记住指针就是一个变量存的是32位数据记住这个才能真正的理解指针。另外 pezy 说有内存漏洞实际上我的完整代码是下面的我大学是acm出身的只有初期才使用真正的指针后期acm中都是使用数组代表指针的这才是真正的升华同样存的是地址这时只不过地址是数组的下标罢了。当然下面的代码我没有使用数组代替指针不然就没法用指针来讲了。最后我加上我的测试的完整代码#include#include#include#include#include#include#include#include#include#include#include#includeusing namespace std;#ifdef __int64typedef __int64 LL;#elsetypedef long long LL;#endifstruct ListNode {int val;ListNode *next;ListNode(int x) : val(x), next(NULL) {}ListNode(int x, ListNode *next) : val(x), next(next) {}ListNode():next(NULL) {}} str[100];ListNode *deleteDuplicates(ListNode *head) {while(head head-next) {if(head-valhead-next-val) {head-next head-next-next;} else {head head-next;}}return head;}ListNode *oldDeleteDuplicates(ListNode *head) {ListNode **pcurhead; //取得 head 变量的if(headNULL||head-nextNULL) {//特判是不是没有元素或者只有一个元素return head;}/*这个时候 head 是 one 的地址。pcur 是 head 的地址。*pcur 就代表 head 了即 one(*pcur)-nex 指向 two,所以不结束循环且比较相等了所以你给 *pcur 赋值也就是给 head 赋值。此时 *pcur 就指向 two 了。*/while((*pcur)-next!NULL) {if((*pcur)-val(*pcur)-next-val) {*pcur(*pcur)-next;// (*pcur)-next ((*pcur)-next-next);} else {pcur((*pcur)-next);}}return head;}void testAsignPoint(ListNode *head) {printf( asign begin%0x\n,head);head head-next;printf( asign begin%0x\n,head);}void myprintf(ListNode* head) {while(head ! NULL) {printf(%d , head-val);headhead-next;}printf(\n);}void testAsignPointAgain(unsigned int addr){printf( asign begin%0x\n,addr);addr (unsigned int)((ListNode *)addr)-next;//28fef8printf( asign begin%0x\n,addr);}void test(ListNode* ptest) {printf(ptest begin%0x\n,ptest);//28fef0testAsignPoint(ptest);printf(one ptest %0x\n,ptest);//28fef0printf(same as before code);testAsignPointAgain((unsigned int)(ptest));printf(one ptest %0x\n,ptest);//28fef0printf(ptest%0x\n,ptest);myprintf(ptest);oldDeleteDuplicates(ptest);myprintf(ptest);deleteDuplicates(ptest);printf(ptest%0x\n,ptest);myprintf(ptest);}void testSample(){ListNode three(1, NULL);ListNode two(0, three);ListNode one(0, two);test(one);}int main() {int n 10;for(int i0; istr[i].val i/2;str[i].next str[i1];}str[n].val n/2;str[n].next NULL;printf(deleteDuplicates begin\n);myprintf(str);deleteDuplicates(str[0]);myprintf(str);printf(deleteDuplicates end\n);printf(\n);printf(test Asign Point begin\n);testSample();printf(test Asign Point begin\n);return 0;}分割线更新时间2014-10-26 15:28先告诉你我对指针的定义:指针可以理解为一个类型或者一类类型。和int,double,自定义类型等是没有区别的。实际上最简洁的代码是下面的样子ListNode *deleteDuplicates(ListNode *head) {while(head head-next) {if(head-valhead-next-val) {head-next head-next-next;} else {head head-next;}}return head;}之所以你使用错误根本原因是由于你错误的理解了指针以指针为参数只会修改指针的值如果对指针变量修改原来那个指针是不受影响的。前端时间刚好我看了一本书《重构~改善既有代码的设计》,里面的一个重构目标就是对于串的指针全部改成 final, java 中没有指针但是传的对象全部是引用如果添加为 final 就是不能给变量赋值但是可以修改对象里面的值。c 语言的 const 也有这个漏洞算是hack做法吧不推荐。扯远了回头来看你的问题不理解的时候最简单的方法就是自己模拟一下。假设有链表有三个元素ListNode three(1, NULL);ListNode two(0, three);ListNode one(0, two);结构是这个样子one - two - three为了传入指针我们事先一个函数吧。void test(ListNode* pTest){printf(head%0x\n,pTest);deleteDuplicates(pTest);printf(head%0x\n,pTest);}test(one);对于这个 pTest以参数形式传给deleteDuplicates由于不是引用所以传进去的是一个32位数据可以称为地址。接下来我们模拟一下你的函数ListNode *oldDeleteDuplicates(ListNode *head) {ListNode **pcurhead; //取得 head 变量的if(headNULL||head-nextNULL) {//特判是不是没有元素或者只有一个元素return head;}/*这个时候 head 和 pTest 的值一样都是 one 的地址。pcur 是 head 的地址。*pcur 就代表 head 了即 one(*pcur)-next 指向 two,所以不结束循环且比较相等了所以你给 *pcur 赋值也就是给 head 赋值。此时 *pcur 就指向 two 了。而此时 pTest 还是指向 one 的而one还是指向two的。模拟至此下面再看看为什么是这个样子。*/while((*pcur)-next!NULL) {if((*pcur)-val(*pcur)-next-val) {*pcur(*pcur)-next;// (*pcur)-next ((*pcur)-next-next);} else {pcur((*pcur)-next);}}return head;}为什么 pTest 没有改变呢我们再测试一下。void testAsignPoint(ListNode *head) {printf( asign begin%0x\n,head);head head-next;printf( asign begin%0x\n,head);}void test(ListNode* ptest) {printf(test begin%0x\n,ptest);testAsignPoint(ptest);printf(test end %0x\n,ptest);}test(one);输出时下面的数据test begin28fef0asign begin28fef0asign begin28fef8test end 28fef0ptest 的地址是不会改变的因为你传的是 ptest 的值而不是 ptest 的地址。分割线原始回答根据你的算法*pcur(*pcur)-next;得到一个结论 当重复时你删除的是前一个但是如果头部重复的时候你只是改变一下指针这样的算法肯定不能解决头部问题的。你需要改变算法为当重复的时候删除后一个。即使后面的你一定要使用你的那个算法那头部就只有特判然后使用 重复时删除后面的 算法删除后一个的算法如下ListNode *deleteDuplicates(ListNode *head) {ListNode **pcurhead;if(headNULL||head-nextNULL) {return head;}while((*pcur)-next!NULL) {if((*pcur)-val(*pcur)-next-val) {// *pcur(*pcur)-next;(*pcur)-next ((*pcur)-next-next);} else {pcur((*pcur)-next);}}return head;}
http://www.yutouwan.com/news/45445/

相关文章:

  • 网站开发与维护总结吸引人的软文
  • 如何用.net做网站网页制作软件html代码编辑器
  • 计算机多媒体辅助教学网站开发万州网络科技有限公司
  • 怎么做wp网站毛绒玩具 东莞网站建设 技术支持
  • 网站制作公司十强常州好一点的网站建设
  • 网站如何实现多语言wordpress apple pro
  • c2c网站开发成本企业网站管理系统联系我们怎么添加
  • 自己搭建网站自己怎么做网站
  • 做美足网站违法吗免费申请qq号注册官网
  • 南方科技大学网站建设怎么做特色网站
  • 网站访问量的单位如何做品牌推广网站
  • 精品网站建设费用 地址磐石网络discuz和WordPress哪个更好
  • 在青岛做阿里巴巴网站找谁哪里可以做游戏视频网站
  • 企业网站推广的方式有哪些WordPress苏醒模板免费
  • 网站seo注意事项创意网站建设设计公司
  • 商务网站建设的六个步骤网站建设既有书籍又有光盘
  • 邮轮哪个网站是可以做特价胃肠的wordpress 安全漏洞
  • 网站内容优化网站大图片优化
  • 买app的网站建设枣庄建设工程管理局网站
  • 在网站做推广属于广告费吗wordpress迁移空间后无法显示图片
  • 苏州企业网站建设公司价格网站备案需要去哪里
  • 温州建设银行支行网站上海专业网站建站品
  • 网站建设教程免费夕滋湖南岚鸿官网linux下可以用wordpress
  • 网站建设过程规划和准备阶段网络营销方法有哪几种
  • 大学生个人网站怎么做那些网站做的非常好看
  • 域名 不做网站泉州免费建站模板
  • 网站建设管理规定门户网站建设调查问卷
  • 比较容易做的网站暖暖 视频 在线 观看 高清
  • 适合在线做笔试的网站网站备案密码收不到
  • 温州哪里可以做企业网站网站如果直接点击拨打电话