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

商城网站源码免费vs2017网站开发教程

商城网站源码免费,vs2017网站开发教程,上海网站备案,做网站有什么方法一#xff1a;暴力求解 1️⃣遍历原链表#xff0c;复制节点尾插 2️⃣更新random#xff0c;原链表中的random对应第几个节点则复制链表中的random就对应第几个 #x1f4d6;Note 不能通过节点中的val判断random的指向#xff0c;因为链表中可能存在两个val相等的节点… 方法一暴力求解 1️⃣遍历原链表复制节点尾插 2️⃣更新random原链表中的random对应第几个节点则复制链表中的random就对应第几个 Note 不能通过节点中的val判断random的指向因为链表中可能存在两个val相等的节点 //创建节点 struct Node* BuyNode(int x) {struct Node* newnode (struct Node*)malloc(sizeof(struct Node));newnode-val x;newnode-next NULL;return newnode; }//找到random对应的节点是第几个 int FindRandom(struct Node* head, struct Node* random) {int count 1;while (head){if (head random){return count;}else {count;head head-next;}}return count; }struct Node* copyRandomList(struct Node* head) {struct Node* guard (struct Node*)malloc(sizeof(struct Node));guard-next NULL;struct Node* tail guard;struct Node* cur head;//复制原链表while (cur){struct Node* newnode BuyNode(cur-val);tail-next newnode;tail tail-next;cur cur-next;}//tail和cur都指向新链表的头tail guard-next;struct Node* tmp head;//更新randomwhile (tail){//在原链表这种判断random指向的节点是第几个int count FindRandom(head, tmp-random);tmp tmp-next;//更新复制链表中的randomcur guard-next;while (count--){tail-random cur;if (cur){cur cur-next;}}tail tail-next;}struct Node* newhead guard-next;free(guard);return newhead;} 方法二 1️⃣拷贝原节点并链接在原节点之后 2️⃣更新拷贝节点中的random 拷贝节点中的random指向的是原节点中random指向节点的下一个节点 3️⃣将拷贝的节点解下来构成新的复制链表 struct Node* copyRandomList(struct Node* head) {struct Node* cur head;struct Node* copy NULL;//拷贝原节点并链接在原节点之后while (cur){copy (struct Node*)malloc(sizeof(struct Node));copy-val cur-val;copy-next cur-next;cur-next copy;cur cur-next-next;}//更新拷贝节点的randomcur head;while (cur){copy cur-next;if (cur-random){copy-random cur-random-next;}else{copy-random NULL;}cur cur-next-next;}//将所有拷贝节点解下来构成新链表并恢复原链表结构cur head;struct Node* copyhead, *copytail;copyhead copytail NULL;while (cur){copy cur-next;//取节点尾插if (copytail NULL){copyhead copytail copy;}else{copytail-next copy;copytail copytail-next;}//恢复原链表cur-next copy-next;cur copy-next;}return copyhead; }
http://www.hkea.cn/news/14516030/

相关文章:

  • 临沂集团网站建设wordpress注册激活码
  • 一个vps主机放两个网站 速度仿制别人的竞价网站做竞价犯法吗
  • 滕州网站建设网站行吗做门户网站建设多少钱
  • 高端品牌网站建设(杭州)wordpress安装到虚拟主机
  • 毕设网站开发需要做什么做网站要会哪些技术
  • 崇文网站开发孝义做网站
  • 网站建设哪些分类网页背景怎么设置
  • 网站空间商盗取数据天津站内关键词优化
  • 纪实摄影网站推荐微信网站设计
  • 网站 设计风格表白网站制作
  • 男女做暧暧试看网站49仙桃做网站找谁
  • 网站建设ktv有专业做网站
  • 珠海电脑自己建网站做视频解析网站要什么服务器
  • 重庆自助建站软件西安建立公司网站的步骤
  • 湘潭手机网站电商设计网站哪个好
  • 网站建设基本流程图片成都电子商务网站建站
  • 常见的网络营销模式济南seo外包公司
  • 上海网站建设sheji021全中文软件开发工具
  • 网站建设与管理课程设计专门做海外服装购的网站有哪些
  • 村镇建设年度报表登录网站专门做网站需要敲代码么
  • 凯里网站建设公司天津网站建设代理商
  • 网站qq一键登录美食门户类网站模版
  • 长治网站制作招聘信息网页设计素材文字
  • 深圳比较好的网站设计公司注册网站用于跳转虚拟货币网站违法
  • 网站集约化建设难点学做网站必须php吗
  • 想做外贸去哪个网站做wordpress 创业
  • 网站信息安全建设方案招代理
  • 云主机做网站成都seo优化推广
  • 宁夏成城建设集团网站网站上的漂浮广告
  • wordpress 主题备份太原seo排名公司