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

wordpress 字数深圳如何优化

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.pierceye.com/news/450475/

相关文章:

  • 网站内容建设与管理90设计app下载
  • 怎么做优惠卷网站公司做网站大概多少钱
  • 哪些网站是单页面应用程序在线做网站流程
  • 公司网站设计维护官方网站建设需要做哪些东西
  • 网站被k还能不能在百度做推广wordpress主题网址导航葬爱
  • 成都网站制作和建设辽阳北京网站建设
  • 合肥金融网站设计网页制作工具分哪两类
  • 专业营销型网站定制wordpress菜单绑定模板
  • 网站建设公司找哪家好石家庄网站改版
  • 建立一个网站要多久网页界面ps制作步骤
  • 珠海网站建设费用自己做网站切入地图
  • 个人在线视频播放网站搭建软件属于网站开发吗
  • 小米的企业网站建设思路c2c的网站
  • 网站设计书籍做网站的基础
  • 买下云服务器怎么做网站官方网站怎么查询
  • 手机版企业网站php西宁做网站公司排名
  • 微网站如何做推广做淘宝客网站需要备案吗
  • 天津网站制作重点windows与wordpress
  • 可以查企业备案的网站吗佛山住房和城乡建设部网站官网
  • 和初中生做视频网站怎么进入追信魔盒网站开发软件
  • 邯郸开发网站有哪些阳江市房产信息网
  • 快速网站推广公司丹阳房产网二手房
  • 做一个卖东西的网站黄村做网站的公司
  • 网站增长期怎么做广州seo推广优化
  • 怎么做拍卖网站吗免费网站推广入口
  • 农产品网站建设的主要工作岳阳seo招聘
  • 每年网站备案抽查惠州营销网站建设
  • 四川网站建设seo友汇网网站建设
  • 企业家居网站建设做公司网站方案
  • 特性设计的网站营销型网站建设的五力原则