文件名称:leetcode下载-CppPracticeCode:Cpp实践代码
文件大小:70KB
文件格式:ZIP
更新时间:2024-07-19 14:08:13
系统开源
leetcode下载 CppPracticeCode 2020/6/6 单链表建立 单链表测长 单链表打印 单链表节点查找 单链表节点插入 单链表节点删除 单链表逆置 寻找单链表中间元素<参考书上> /* 解决办法(时间复杂度O(n)): 1.设置两个指针:middle中间元素、current当前遍历的元素,先让两指针指向头节点 2.设置两个序列记录:index_m(middle指针当前所指的位置)、index_c(current指针当前指的位置),初始化为0 3.使用current指针遍历链表同时index_c++ 4.遍历时判断index_m是否小于1/2 * index_c如果是则让middle指针前进并让index_m++直到index_m = 1/2*index_c 5.遍历结束后current指向的即为中间元素 */ Node *SearchCenter(Node *head) { Node* curret = head; //当前位置指针 Node* center = head; //中间节点指针 int t_index = 0; //当前节点指针指向的第几个元素 int
【文件预览】:
CppPracticeCode-master
----base()
--------commonstring.cpp(968B)
--------addbigint.cpp(2KB)
--------test.cpp(154B)
--------ptr.cpp(149B)
--------strstr.cpp(844B)
--------auto_ptr.cpp(332B)
--------reverse.cpp(1KB)
--------a.out(14KB)
--------my_strcpy.cpp(1011B)
--------string_to_num.cpp(1KB)
--------revstr.cpp(937B)
--------is_rev_str.cpp(612B)
--------my_memcpy.cpp(601B)
--------my_strlen.cpp(478B)
--------my_auto_ptr.cpp(817B)
--------num_to_string.cpp(2KB)
--------my_strrev.cpp(866B)
--------pt(9KB)
--------transfmt.cpp(1017B)
--------my_stcmp.cpp(799B)
----DataStructure()
--------linked()
--------sort()
----README.md(11KB)
----UNIXBasePractice()
--------execl.cpp(598B)
--------a.out(9KB)
--------execlp.cpp(517B)
--------vfork_demo.cpp(397B)
--------fork.cpp(663B)
--------fork_demo.cpp(558B)
----UNIXNetWorkProgramming()
--------gettime.cpp(2KB)
--------a.out(13KB)
--------time_fork_s.cpp(691B)
--------time_server_ip.cpp(920B)
--------timeclient(20KB)
--------timeserver(13KB)
--------time_server.cpp(2KB)
--------makefile(6B)
--------iptimeserver(20KB)
--------test_host_byte_order.cpp(490B)
----shell()
--------test.sh(313B)
----c.txt(778B)