diff --git a/线性表/链式实现大题/P40.1/.vs/P40.1/v16/.suo b/线性表/链式实现大题/P40.1/.vs/P40.1/v16/.suo new file mode 100644 index 0000000..c3d98a7 Binary files /dev/null and b/线性表/链式实现大题/P40.1/.vs/P40.1/v16/.suo differ diff --git a/线性表/链式实现大题/P40.1/.vs/P40.1/v16/Browse.VC.db b/线性表/链式实现大题/P40.1/.vs/P40.1/v16/Browse.VC.db new file mode 100644 index 0000000..d39c0c3 Binary files /dev/null and b/线性表/链式实现大题/P40.1/.vs/P40.1/v16/Browse.VC.db differ diff --git a/线性表/链式实现大题/P40.1/.vs/P40.1/v16/ipch/AutoPCH/39b559e524427c94/P40.1.ipch b/线性表/链式实现大题/P40.1/.vs/P40.1/v16/ipch/AutoPCH/39b559e524427c94/P40.1.ipch new file mode 100644 index 0000000..37008f9 Binary files /dev/null and b/线性表/链式实现大题/P40.1/.vs/P40.1/v16/ipch/AutoPCH/39b559e524427c94/P40.1.ipch differ diff --git a/线性表/链式实现大题/P40.1/.vs/P40.1/v16/ipch/AutoPCH/6ed141ce75595748/P40.1.ipch b/线性表/链式实现大题/P40.1/.vs/P40.1/v16/ipch/AutoPCH/6ed141ce75595748/P40.1.ipch new file mode 100644 index 0000000..ed3d19d Binary files /dev/null and b/线性表/链式实现大题/P40.1/.vs/P40.1/v16/ipch/AutoPCH/6ed141ce75595748/P40.1.ipch differ diff --git a/线性表/链式实现大题/P40.1/Debug/P40.1.exe b/线性表/链式实现大题/P40.1/Debug/P40.1.exe new file mode 100644 index 0000000..e2e1da9 Binary files /dev/null and b/线性表/链式实现大题/P40.1/Debug/P40.1.exe differ diff --git a/线性表/链式实现大题/P40.1/Debug/P40.1.exe.recipe b/线性表/链式实现大题/P40.1/Debug/P40.1.exe.recipe new file mode 100644 index 0000000..50a9c10 --- /dev/null +++ b/线性表/链式实现大题/P40.1/Debug/P40.1.exe.recipe @@ -0,0 +1,11 @@ + + + + + D:\college\code\C(C++)_CODE\考研数据结构\链式实现大题\P40.1\Debug\P40.1.exe + + + + + + \ No newline at end of file diff --git a/线性表/链式实现大题/P40.1/Debug/P40.1.ilk b/线性表/链式实现大题/P40.1/Debug/P40.1.ilk new file mode 100644 index 0000000..3a0ee65 Binary files /dev/null and b/线性表/链式实现大题/P40.1/Debug/P40.1.ilk differ diff --git a/线性表/链式实现大题/P40.1/Debug/P40.1.log b/线性表/链式实现大题/P40.1/Debug/P40.1.log new file mode 100644 index 0000000..4cf686d --- /dev/null +++ b/线性表/链式实现大题/P40.1/Debug/P40.1.log @@ -0,0 +1,3 @@ + P40.1.cpp +D:\college\code\C(C++)_CODE\考研数据结构\链式实现大题\P40.1\P40.1.cpp(40,2): warning C4018: '<': signed/unsigned mismatch + P40.1.vcxproj -> D:\college\code\C(C++)_CODE\考研数据结构\链式实现大题\P40.1\Debug\P40.1.exe diff --git a/线性表/链式实现大题/P40.1/Debug/P40.1.obj b/线性表/链式实现大题/P40.1/Debug/P40.1.obj new file mode 100644 index 0000000..b07f416 Binary files /dev/null and b/线性表/链式实现大题/P40.1/Debug/P40.1.obj differ diff --git a/线性表/链式实现大题/P40.1/Debug/P40.1.pdb b/线性表/链式实现大题/P40.1/Debug/P40.1.pdb new file mode 100644 index 0000000..a75e613 Binary files /dev/null and b/线性表/链式实现大题/P40.1/Debug/P40.1.pdb differ diff --git a/线性表/链式实现大题/P40.1/Debug/P40.1.tlog/CL.command.1.tlog b/线性表/链式实现大题/P40.1/Debug/P40.1.tlog/CL.command.1.tlog new file mode 100644 index 0000000..0d619b5 Binary files /dev/null and b/线性表/链式实现大题/P40.1/Debug/P40.1.tlog/CL.command.1.tlog differ diff --git a/线性表/链式实现大题/P40.1/Debug/P40.1.tlog/CL.read.1.tlog b/线性表/链式实现大题/P40.1/Debug/P40.1.tlog/CL.read.1.tlog new file mode 100644 index 0000000..3892b59 Binary files /dev/null and b/线性表/链式实现大题/P40.1/Debug/P40.1.tlog/CL.read.1.tlog differ diff --git a/线性表/链式实现大题/P40.1/Debug/P40.1.tlog/CL.write.1.tlog b/线性表/链式实现大题/P40.1/Debug/P40.1.tlog/CL.write.1.tlog new file mode 100644 index 0000000..d55d1ab Binary files /dev/null and b/线性表/链式实现大题/P40.1/Debug/P40.1.tlog/CL.write.1.tlog differ diff --git a/线性表/链式实现大题/P40.1/Debug/P40.1.tlog/P40.1.lastbuildstate b/线性表/链式实现大题/P40.1/Debug/P40.1.tlog/P40.1.lastbuildstate new file mode 100644 index 0000000..e767ee1 --- /dev/null +++ b/线性表/链式实现大题/P40.1/Debug/P40.1.tlog/P40.1.lastbuildstate @@ -0,0 +1,2 @@ +PlatformToolSet=v142:VCToolArchitecture=Native32Bit:VCToolsVersion=14.28.29333:TargetPlatformVersion=10.0.18362.0: +Debug|Win32|D:\college\code\C(C++)_CODE\考研数据结构\链式实现大题\P40.1\| diff --git a/线性表/链式实现大题/P40.1/Debug/P40.1.tlog/link.command.1.tlog b/线性表/链式实现大题/P40.1/Debug/P40.1.tlog/link.command.1.tlog new file mode 100644 index 0000000..96a7ebd Binary files /dev/null and b/线性表/链式实现大题/P40.1/Debug/P40.1.tlog/link.command.1.tlog differ diff --git a/线性表/链式实现大题/P40.1/Debug/P40.1.tlog/link.read.1.tlog b/线性表/链式实现大题/P40.1/Debug/P40.1.tlog/link.read.1.tlog new file mode 100644 index 0000000..a92b6cd Binary files /dev/null and b/线性表/链式实现大题/P40.1/Debug/P40.1.tlog/link.read.1.tlog differ diff --git a/线性表/链式实现大题/P40.1/Debug/P40.1.tlog/link.write.1.tlog b/线性表/链式实现大题/P40.1/Debug/P40.1.tlog/link.write.1.tlog new file mode 100644 index 0000000..279d12a Binary files /dev/null and b/线性表/链式实现大题/P40.1/Debug/P40.1.tlog/link.write.1.tlog differ diff --git a/线性表/链式实现大题/P40.1/Debug/P40.1.vcxproj.FileListAbsolute.txt b/线性表/链式实现大题/P40.1/Debug/P40.1.vcxproj.FileListAbsolute.txt new file mode 100644 index 0000000..eac8839 --- /dev/null +++ b/线性表/链式实现大题/P40.1/Debug/P40.1.vcxproj.FileListAbsolute.txt @@ -0,0 +1,4 @@ +D:\college\code\C(C++)_CODE\考研数据结构\链式实现大题\1\P40.1\Debug\P40.1.exe +D:\college\code\C(C++)_CODE\考研数据结构\链式实现大题\1\P40.1\Debug\P40.1.pdb +D:\college\code\C(C++)_CODE\考研数据结构\链式实现大题\P40.1\Debug\P40.1.exe +D:\college\code\C(C++)_CODE\考研数据结构\链式实现大题\P40.1\Debug\P40.1.pdb diff --git a/线性表/链式实现大题/P40.1/Debug/vc142.idb b/线性表/链式实现大题/P40.1/Debug/vc142.idb new file mode 100644 index 0000000..c9f4127 Binary files /dev/null and b/线性表/链式实现大题/P40.1/Debug/vc142.idb differ diff --git a/线性表/链式实现大题/P40.1/Debug/vc142.pdb b/线性表/链式实现大题/P40.1/Debug/vc142.pdb new file mode 100644 index 0000000..331f407 Binary files /dev/null and b/线性表/链式实现大题/P40.1/Debug/vc142.pdb differ diff --git a/线性表/链式实现大题/P40.1/P40.1.cpp b/线性表/链式实现大题/P40.1/P40.1.cpp new file mode 100644 index 0000000..ffc6614 --- /dev/null +++ b/线性表/链式实现大题/P40.1/P40.1.cpp @@ -0,0 +1,85 @@ +#include +#include +using namespace std; + +//P40.1 +//没计一个递归算法, 删除不带头结点的单链表中所有值为×的结点 + +#define ElemType int +#define _for(i,a,b) for(int i=(a);i<(b);i++) + + +#pragma region 建立不带头结点的链表 + +typedef struct LNode { + ElemType data; + struct LNode* next; +}LNode, * LinkList; + +//初始化链表 +bool InitList(LinkList &L) { + L = NULL; + return true; +} + + +//判断是否为空 +bool IsEmpty(LinkList L) { + return (L == NULL); +} + +//使用尾插法建表 +LinkList CreatList(vector data) { + if (data.size() < 1) { + return NULL; + } + //头结点 + LNode* head = (LinkList)malloc(sizeof(LNode)); + head->data = data[0]; + head->next = NULL; + LinkList p = head; + _for(i, 1, data.size()) { + LNode* s = (LinkList)malloc(sizeof(LNode)); + s->data = data[i]; + s->next = NULL; + p->next = s; + p = s; + } + return head; +} +//输出链表 +void PrintList(LinkList list) { + while (list != NULL) { + printf("%d ", list->data); + list = list->next; + } + printf("\n"); +} + +#pragma endregion + + +//P40.1 +void DeleteXNode(LinkList &head, ElemType X) { + if (head == NULL) return; + if (head->data != X) { + return DeleteXNode(head->next, X); + } + LNode* q = head; + head = head->next; + delete q; + return DeleteXNode(head, X); +} + + +int main() +{ + vector data{ 2,4,6,4,6,3,6,41 }; + LinkList head; + InitList(head); + head = CreatList(data); + PrintList(head); + DeleteXNode(head, 6); + PrintList(head); + return 0; +} diff --git a/线性表/链式实现大题/P40.1/P40.1.sln b/线性表/链式实现大题/P40.1/P40.1.sln new file mode 100644 index 0000000..562fc2c --- /dev/null +++ b/线性表/链式实现大题/P40.1/P40.1.sln @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.30804.86 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "P40.1", "P40.1.vcxproj", "{6FBE2DD3-5938-43F5-8D38-F99BD5C9F83B}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {6FBE2DD3-5938-43F5-8D38-F99BD5C9F83B}.Debug|x64.ActiveCfg = Debug|x64 + {6FBE2DD3-5938-43F5-8D38-F99BD5C9F83B}.Debug|x64.Build.0 = Debug|x64 + {6FBE2DD3-5938-43F5-8D38-F99BD5C9F83B}.Debug|x86.ActiveCfg = Debug|Win32 + {6FBE2DD3-5938-43F5-8D38-F99BD5C9F83B}.Debug|x86.Build.0 = Debug|Win32 + {6FBE2DD3-5938-43F5-8D38-F99BD5C9F83B}.Release|x64.ActiveCfg = Release|x64 + {6FBE2DD3-5938-43F5-8D38-F99BD5C9F83B}.Release|x64.Build.0 = Release|x64 + {6FBE2DD3-5938-43F5-8D38-F99BD5C9F83B}.Release|x86.ActiveCfg = Release|Win32 + {6FBE2DD3-5938-43F5-8D38-F99BD5C9F83B}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {003D253E-162B-4239-8D70-04072966FFF5} + EndGlobalSection +EndGlobal diff --git a/线性表/链式实现大题/P40.1/P40.1.vcxproj b/线性表/链式实现大题/P40.1/P40.1.vcxproj new file mode 100644 index 0000000..ab3c0c5 --- /dev/null +++ b/线性表/链式实现大题/P40.1/P40.1.vcxproj @@ -0,0 +1,147 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 16.0 + Win32Proj + {6fbe2dd3-5938-43f5-8d38-f99bd5c9f83b} + P401 + 10.0 + + + + Application + true + v142 + Unicode + + + Application + false + v142 + true + Unicode + + + Application + true + v142 + Unicode + + + Application + false + v142 + true + Unicode + + + + + + + + + + + + + + + + + + + + + true + + + false + + + true + + + false + + + + Level3 + true + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + true + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + Level3 + true + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + + + + + \ No newline at end of file diff --git a/线性表/链式实现大题/P40.1/P40.1.vcxproj.filters b/线性表/链式实现大题/P40.1/P40.1.vcxproj.filters new file mode 100644 index 0000000..5da769c --- /dev/null +++ b/线性表/链式实现大题/P40.1/P40.1.vcxproj.filters @@ -0,0 +1,22 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Source Files + + + \ No newline at end of file diff --git a/线性表/链式实现大题/P40.1/P40.1.vcxproj.user b/线性表/链式实现大题/P40.1/P40.1.vcxproj.user new file mode 100644 index 0000000..88a5509 --- /dev/null +++ b/线性表/链式实现大题/P40.1/P40.1.vcxproj.user @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/线性表/链式实现大题/P40.2/.vs/P40.2/v16/.suo b/线性表/链式实现大题/P40.2/.vs/P40.2/v16/.suo new file mode 100644 index 0000000..243a548 Binary files /dev/null and b/线性表/链式实现大题/P40.2/.vs/P40.2/v16/.suo differ diff --git a/线性表/链式实现大题/P40.2/.vs/P40.2/v16/Browse.VC.db b/线性表/链式实现大题/P40.2/.vs/P40.2/v16/Browse.VC.db new file mode 100644 index 0000000..a1a0251 Binary files /dev/null and b/线性表/链式实现大题/P40.2/.vs/P40.2/v16/Browse.VC.db differ diff --git a/线性表/链式实现大题/P40.2/.vs/P40.2/v16/ipch/AutoPCH/385149c0d183a0e8/P40.2.ipch b/线性表/链式实现大题/P40.2/.vs/P40.2/v16/ipch/AutoPCH/385149c0d183a0e8/P40.2.ipch new file mode 100644 index 0000000..c971472 Binary files /dev/null and b/线性表/链式实现大题/P40.2/.vs/P40.2/v16/ipch/AutoPCH/385149c0d183a0e8/P40.2.ipch differ diff --git a/线性表/链式实现大题/P40.2/Debug/P40.2.exe b/线性表/链式实现大题/P40.2/Debug/P40.2.exe new file mode 100644 index 0000000..cb7c6f8 Binary files /dev/null and b/线性表/链式实现大题/P40.2/Debug/P40.2.exe differ diff --git a/线性表/链式实现大题/P40.2/Debug/P40.2.exe.recipe b/线性表/链式实现大题/P40.2/Debug/P40.2.exe.recipe new file mode 100644 index 0000000..6923f3e --- /dev/null +++ b/线性表/链式实现大题/P40.2/Debug/P40.2.exe.recipe @@ -0,0 +1,11 @@ + + + + + D:\college\code\C(C++)_CODE\考研数据结构\链式实现大题\P40.2\Debug\P40.2.exe + + + + + + \ No newline at end of file diff --git a/线性表/链式实现大题/P40.2/Debug/P40.2.ilk b/线性表/链式实现大题/P40.2/Debug/P40.2.ilk new file mode 100644 index 0000000..9d25c88 Binary files /dev/null and b/线性表/链式实现大题/P40.2/Debug/P40.2.ilk differ diff --git a/线性表/链式实现大题/P40.2/Debug/P40.2.log b/线性表/链式实现大题/P40.2/Debug/P40.2.log new file mode 100644 index 0000000..1319d42 --- /dev/null +++ b/线性表/链式实现大题/P40.2/Debug/P40.2.log @@ -0,0 +1,3 @@ + P40.2.cpp +D:\college\code\C(C++)_CODE\考研数据结构\链式实现大题\P40.2\P40.2.cpp(47,2): warning C4018: '<': signed/unsigned mismatch + P40.2.vcxproj -> D:\college\code\C(C++)_CODE\考研数据结构\链式实现大题\P40.2\Debug\P40.2.exe diff --git a/线性表/链式实现大题/P40.2/Debug/P40.2.obj b/线性表/链式实现大题/P40.2/Debug/P40.2.obj new file mode 100644 index 0000000..e28681f Binary files /dev/null and b/线性表/链式实现大题/P40.2/Debug/P40.2.obj differ diff --git a/线性表/链式实现大题/P40.2/Debug/P40.2.pdb b/线性表/链式实现大题/P40.2/Debug/P40.2.pdb new file mode 100644 index 0000000..1ef0fc7 Binary files /dev/null and b/线性表/链式实现大题/P40.2/Debug/P40.2.pdb differ diff --git a/线性表/链式实现大题/P40.2/Debug/P40.2.tlog/CL.command.1.tlog b/线性表/链式实现大题/P40.2/Debug/P40.2.tlog/CL.command.1.tlog new file mode 100644 index 0000000..07bd330 Binary files /dev/null and b/线性表/链式实现大题/P40.2/Debug/P40.2.tlog/CL.command.1.tlog differ diff --git a/线性表/链式实现大题/P40.2/Debug/P40.2.tlog/CL.read.1.tlog b/线性表/链式实现大题/P40.2/Debug/P40.2.tlog/CL.read.1.tlog new file mode 100644 index 0000000..3aca29d Binary files /dev/null and b/线性表/链式实现大题/P40.2/Debug/P40.2.tlog/CL.read.1.tlog differ diff --git a/线性表/链式实现大题/P40.2/Debug/P40.2.tlog/CL.write.1.tlog b/线性表/链式实现大题/P40.2/Debug/P40.2.tlog/CL.write.1.tlog new file mode 100644 index 0000000..a3f31f1 Binary files /dev/null and b/线性表/链式实现大题/P40.2/Debug/P40.2.tlog/CL.write.1.tlog differ diff --git a/线性表/链式实现大题/P40.2/Debug/P40.2.tlog/P40.2.lastbuildstate b/线性表/链式实现大题/P40.2/Debug/P40.2.tlog/P40.2.lastbuildstate new file mode 100644 index 0000000..5cf3bd8 --- /dev/null +++ b/线性表/链式实现大题/P40.2/Debug/P40.2.tlog/P40.2.lastbuildstate @@ -0,0 +1,2 @@ +PlatformToolSet=v142:VCToolArchitecture=Native32Bit:VCToolsVersion=14.28.29333:TargetPlatformVersion=10.0.18362.0: +Debug|Win32|D:\college\code\C(C++)_CODE\考研数据结构\链式实现大题\P40.2\| diff --git a/线性表/链式实现大题/P40.2/Debug/P40.2.tlog/link.command.1.tlog b/线性表/链式实现大题/P40.2/Debug/P40.2.tlog/link.command.1.tlog new file mode 100644 index 0000000..3f5ebf5 Binary files /dev/null and b/线性表/链式实现大题/P40.2/Debug/P40.2.tlog/link.command.1.tlog differ diff --git a/线性表/链式实现大题/P40.2/Debug/P40.2.tlog/link.read.1.tlog b/线性表/链式实现大题/P40.2/Debug/P40.2.tlog/link.read.1.tlog new file mode 100644 index 0000000..ddbc7d0 Binary files /dev/null and b/线性表/链式实现大题/P40.2/Debug/P40.2.tlog/link.read.1.tlog differ diff --git a/线性表/链式实现大题/P40.2/Debug/P40.2.tlog/link.write.1.tlog b/线性表/链式实现大题/P40.2/Debug/P40.2.tlog/link.write.1.tlog new file mode 100644 index 0000000..e99fdbf Binary files /dev/null and b/线性表/链式实现大题/P40.2/Debug/P40.2.tlog/link.write.1.tlog differ diff --git a/线性表/链式实现大题/P40.2/Debug/P40.2.vcxproj.FileListAbsolute.txt b/线性表/链式实现大题/P40.2/Debug/P40.2.vcxproj.FileListAbsolute.txt new file mode 100644 index 0000000..85794c8 --- /dev/null +++ b/线性表/链式实现大题/P40.2/Debug/P40.2.vcxproj.FileListAbsolute.txt @@ -0,0 +1,2 @@ +D:\college\code\C(C++)_CODE\考研数据结构\链式实现大题\P40.2\Debug\P40.2.exe +D:\college\code\C(C++)_CODE\考研数据结构\链式实现大题\P40.2\Debug\P40.2.pdb diff --git a/线性表/链式实现大题/P40.2/Debug/vc142.idb b/线性表/链式实现大题/P40.2/Debug/vc142.idb new file mode 100644 index 0000000..24c345d Binary files /dev/null and b/线性表/链式实现大题/P40.2/Debug/vc142.idb differ diff --git a/线性表/链式实现大题/P40.2/Debug/vc142.pdb b/线性表/链式实现大题/P40.2/Debug/vc142.pdb new file mode 100644 index 0000000..ee37a4c Binary files /dev/null and b/线性表/链式实现大题/P40.2/Debug/vc142.pdb differ diff --git a/线性表/链式实现大题/P40.2/P40.2.cpp b/线性表/链式实现大题/P40.2/P40.2.cpp new file mode 100644 index 0000000..a5520f1 --- /dev/null +++ b/线性表/链式实现大题/P40.2/P40.2.cpp @@ -0,0 +1,101 @@ +#include +#include +using namespace std; + +//P40.2 +//在带头结点的单链表中, 删除所有值为x的结点, 并释放其空间, 假设值为x的结点 +//不唯一, 试编写算法以实现上述操作 + +#define ElemType int +#define _for(i,a,b) for(int i=(a);i<(b);i++) + + +#pragma region 建立带头结点的链表 + +typedef struct LNode { + ElemType data; + struct LNode* next; +}LNode, * LinkList; + +//初始化链表 +bool InitList(LinkList& L) { + //分配一个头结点 + L = (LNode*)malloc(sizeof(LNode)); + //内存不足,分配失败 + if (L == NULL) { + return false; + } + //头结点之后暂时还没有节点 + L->next = NULL; + return true; +} + + +//判断是否为空 +bool IsEmpty(LinkList L) { + return ((L->next) == NULL); +} + +//使用尾插法建表 +LinkList CreatList(vector data) { + if (data.size() < 1) { + return NULL; + } + //头结点 + LNode* head = (LinkList)malloc(sizeof(LNode)); + head->data = NULL; + head->next = NULL; + LinkList p = head; + _for(i, 0, data.size()) { + LNode* s = (LinkList)malloc(sizeof(LNode)); + s->data = data[i]; + s->next = NULL; + p->next = s; + p = s; + } + return head; +} +//输出链表 +void PrintList(LinkList list) { + list = list->next; + while (list != NULL) { + printf("%d ", list->data); + list = list->next; + } + printf("\n"); +} + +#pragma endregion + + +//P40.2 +LinkList DeleteXNode(LinkList &head, ElemType X) { + LinkList p = head->next; + LinkList q = head; + while (p != NULL) { + if (p->data == X) { + LNode* d = p; + q->next = p->next; + p = p->next; + delete d; + } + else { + q = p; + p = p->next; + } + } + return head; +} + + +int main() +{ + vector data{ 2,4,6,6,6,3,6,41 }; + LinkList head; + InitList(head); + head = CreatList(data); + PrintList(head); + head = DeleteXNode(head, 6); + PrintList(head); + return 0; +} diff --git a/线性表/链式实现大题/P40.2/P40.2.sln b/线性表/链式实现大题/P40.2/P40.2.sln new file mode 100644 index 0000000..d82a6a2 --- /dev/null +++ b/线性表/链式实现大题/P40.2/P40.2.sln @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.30804.86 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "P40.2", "P40.2.vcxproj", "{779EE9C0-7683-4061-AC53-35E5335E189F}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {779EE9C0-7683-4061-AC53-35E5335E189F}.Debug|x64.ActiveCfg = Debug|x64 + {779EE9C0-7683-4061-AC53-35E5335E189F}.Debug|x64.Build.0 = Debug|x64 + {779EE9C0-7683-4061-AC53-35E5335E189F}.Debug|x86.ActiveCfg = Debug|Win32 + {779EE9C0-7683-4061-AC53-35E5335E189F}.Debug|x86.Build.0 = Debug|Win32 + {779EE9C0-7683-4061-AC53-35E5335E189F}.Release|x64.ActiveCfg = Release|x64 + {779EE9C0-7683-4061-AC53-35E5335E189F}.Release|x64.Build.0 = Release|x64 + {779EE9C0-7683-4061-AC53-35E5335E189F}.Release|x86.ActiveCfg = Release|Win32 + {779EE9C0-7683-4061-AC53-35E5335E189F}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {DA1417F4-DD79-4843-8BE9-3F4186D7A991} + EndGlobalSection +EndGlobal diff --git a/线性表/链式实现大题/P40.2/P40.2.vcxproj b/线性表/链式实现大题/P40.2/P40.2.vcxproj new file mode 100644 index 0000000..58c3dd3 --- /dev/null +++ b/线性表/链式实现大题/P40.2/P40.2.vcxproj @@ -0,0 +1,147 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 16.0 + Win32Proj + {779ee9c0-7683-4061-ac53-35e5335e189f} + P402 + 10.0 + + + + Application + true + v142 + Unicode + + + Application + false + v142 + true + Unicode + + + Application + true + v142 + Unicode + + + Application + false + v142 + true + Unicode + + + + + + + + + + + + + + + + + + + + + true + + + false + + + true + + + false + + + + Level3 + true + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + true + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + Level3 + true + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + + + + + \ No newline at end of file diff --git a/线性表/链式实现大题/P40.2/P40.2.vcxproj.filters b/线性表/链式实现大题/P40.2/P40.2.vcxproj.filters new file mode 100644 index 0000000..8c82035 --- /dev/null +++ b/线性表/链式实现大题/P40.2/P40.2.vcxproj.filters @@ -0,0 +1,22 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Source Files + + + \ No newline at end of file diff --git a/线性表/链式实现大题/P40.2/P40.2.vcxproj.user b/线性表/链式实现大题/P40.2/P40.2.vcxproj.user new file mode 100644 index 0000000..88a5509 --- /dev/null +++ b/线性表/链式实现大题/P40.2/P40.2.vcxproj.user @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/线性表/链式实现大题/P40.3/.vs/P40.3/v16/.suo b/线性表/链式实现大题/P40.3/.vs/P40.3/v16/.suo new file mode 100644 index 0000000..eb2434a Binary files /dev/null and b/线性表/链式实现大题/P40.3/.vs/P40.3/v16/.suo differ diff --git a/线性表/链式实现大题/P40.3/.vs/P40.3/v16/Browse.VC.db b/线性表/链式实现大题/P40.3/.vs/P40.3/v16/Browse.VC.db new file mode 100644 index 0000000..b405994 Binary files /dev/null and b/线性表/链式实现大题/P40.3/.vs/P40.3/v16/Browse.VC.db differ diff --git a/线性表/链式实现大题/P40.3/.vs/P40.3/v16/ipch/AutoPCH/de2427c13903ed88/P40.3.ipch b/线性表/链式实现大题/P40.3/.vs/P40.3/v16/ipch/AutoPCH/de2427c13903ed88/P40.3.ipch new file mode 100644 index 0000000..603927e Binary files /dev/null and b/线性表/链式实现大题/P40.3/.vs/P40.3/v16/ipch/AutoPCH/de2427c13903ed88/P40.3.ipch differ diff --git a/线性表/链式实现大题/P40.3/Debug/P40.3.exe b/线性表/链式实现大题/P40.3/Debug/P40.3.exe new file mode 100644 index 0000000..8a75487 Binary files /dev/null and b/线性表/链式实现大题/P40.3/Debug/P40.3.exe differ diff --git a/线性表/链式实现大题/P40.3/Debug/P40.3.exe.recipe b/线性表/链式实现大题/P40.3/Debug/P40.3.exe.recipe new file mode 100644 index 0000000..f24f982 --- /dev/null +++ b/线性表/链式实现大题/P40.3/Debug/P40.3.exe.recipe @@ -0,0 +1,11 @@ + + + + + D:\college\code\C(C++)_CODE\考研数据结构\链式实现大题\P40.3\Debug\P40.3.exe + + + + + + \ No newline at end of file diff --git a/线性表/链式实现大题/P40.3/Debug/P40.3.ilk b/线性表/链式实现大题/P40.3/Debug/P40.3.ilk new file mode 100644 index 0000000..343b506 Binary files /dev/null and b/线性表/链式实现大题/P40.3/Debug/P40.3.ilk differ diff --git a/线性表/链式实现大题/P40.3/Debug/P40.3.log b/线性表/链式实现大题/P40.3/Debug/P40.3.log new file mode 100644 index 0000000..7d5f2df --- /dev/null +++ b/线性表/链式实现大题/P40.3/Debug/P40.3.log @@ -0,0 +1,3 @@ + P40.3.cpp +D:\college\code\C(C++)_CODE\考研数据结构\链式实现大题\P40.3\P40.3.cpp(47,2): warning C4018: '<': signed/unsigned mismatch + P40.3.vcxproj -> D:\college\code\C(C++)_CODE\考研数据结构\链式实现大题\P40.3\Debug\P40.3.exe diff --git a/线性表/链式实现大题/P40.3/Debug/P40.3.obj b/线性表/链式实现大题/P40.3/Debug/P40.3.obj new file mode 100644 index 0000000..16a7c57 Binary files /dev/null and b/线性表/链式实现大题/P40.3/Debug/P40.3.obj differ diff --git a/线性表/链式实现大题/P40.3/Debug/P40.3.pdb b/线性表/链式实现大题/P40.3/Debug/P40.3.pdb new file mode 100644 index 0000000..f6fe195 Binary files /dev/null and b/线性表/链式实现大题/P40.3/Debug/P40.3.pdb differ diff --git a/线性表/链式实现大题/P40.3/Debug/P40.3.tlog/CL.command.1.tlog b/线性表/链式实现大题/P40.3/Debug/P40.3.tlog/CL.command.1.tlog new file mode 100644 index 0000000..519e799 Binary files /dev/null and b/线性表/链式实现大题/P40.3/Debug/P40.3.tlog/CL.command.1.tlog differ diff --git a/线性表/链式实现大题/P40.3/Debug/P40.3.tlog/CL.read.1.tlog b/线性表/链式实现大题/P40.3/Debug/P40.3.tlog/CL.read.1.tlog new file mode 100644 index 0000000..51cf947 Binary files /dev/null and b/线性表/链式实现大题/P40.3/Debug/P40.3.tlog/CL.read.1.tlog differ diff --git a/线性表/链式实现大题/P40.3/Debug/P40.3.tlog/CL.write.1.tlog b/线性表/链式实现大题/P40.3/Debug/P40.3.tlog/CL.write.1.tlog new file mode 100644 index 0000000..d08306e Binary files /dev/null and b/线性表/链式实现大题/P40.3/Debug/P40.3.tlog/CL.write.1.tlog differ diff --git a/线性表/链式实现大题/P40.3/Debug/P40.3.tlog/P40.3.lastbuildstate b/线性表/链式实现大题/P40.3/Debug/P40.3.tlog/P40.3.lastbuildstate new file mode 100644 index 0000000..0339121 --- /dev/null +++ b/线性表/链式实现大题/P40.3/Debug/P40.3.tlog/P40.3.lastbuildstate @@ -0,0 +1,2 @@ +PlatformToolSet=v142:VCToolArchitecture=Native32Bit:VCToolsVersion=14.28.29333:TargetPlatformVersion=10.0.18362.0: +Debug|Win32|D:\college\code\C(C++)_CODE\考研数据结构\链式实现大题\P40.3\| diff --git a/线性表/链式实现大题/P40.3/Debug/P40.3.tlog/link.command.1.tlog b/线性表/链式实现大题/P40.3/Debug/P40.3.tlog/link.command.1.tlog new file mode 100644 index 0000000..570094d Binary files /dev/null and b/线性表/链式实现大题/P40.3/Debug/P40.3.tlog/link.command.1.tlog differ diff --git a/线性表/链式实现大题/P40.3/Debug/P40.3.tlog/link.read.1.tlog b/线性表/链式实现大题/P40.3/Debug/P40.3.tlog/link.read.1.tlog new file mode 100644 index 0000000..915ed6d Binary files /dev/null and b/线性表/链式实现大题/P40.3/Debug/P40.3.tlog/link.read.1.tlog differ diff --git a/线性表/链式实现大题/P40.3/Debug/P40.3.tlog/link.write.1.tlog b/线性表/链式实现大题/P40.3/Debug/P40.3.tlog/link.write.1.tlog new file mode 100644 index 0000000..c04eb62 Binary files /dev/null and b/线性表/链式实现大题/P40.3/Debug/P40.3.tlog/link.write.1.tlog differ diff --git a/线性表/链式实现大题/P40.3/Debug/P40.3.vcxproj.FileListAbsolute.txt b/线性表/链式实现大题/P40.3/Debug/P40.3.vcxproj.FileListAbsolute.txt new file mode 100644 index 0000000..d8f5e54 --- /dev/null +++ b/线性表/链式实现大题/P40.3/Debug/P40.3.vcxproj.FileListAbsolute.txt @@ -0,0 +1,2 @@ +D:\college\code\C(C++)_CODE\考研数据结构\链式实现大题\P40.3\Debug\P40.3.exe +D:\college\code\C(C++)_CODE\考研数据结构\链式实现大题\P40.3\Debug\P40.3.pdb diff --git a/线性表/链式实现大题/P40.3/Debug/vc142.idb b/线性表/链式实现大题/P40.3/Debug/vc142.idb new file mode 100644 index 0000000..7e62bb0 Binary files /dev/null and b/线性表/链式实现大题/P40.3/Debug/vc142.idb differ diff --git a/线性表/链式实现大题/P40.3/Debug/vc142.pdb b/线性表/链式实现大题/P40.3/Debug/vc142.pdb new file mode 100644 index 0000000..d680951 Binary files /dev/null and b/线性表/链式实现大题/P40.3/Debug/vc142.pdb differ diff --git a/线性表/链式实现大题/P40.3/P40.3.cpp b/线性表/链式实现大题/P40.3/P40.3.cpp new file mode 100644 index 0000000..b3bab97 --- /dev/null +++ b/线性表/链式实现大题/P40.3/P40.3.cpp @@ -0,0 +1,86 @@ +#include +#include +using namespace std; + +//P40.3 +//设L为带头结点的单链表,编写算法实现从尾到头反向输出每个结点的值 +#define ElemType int +#define _for(i,a,b) for(int i=(a);i<(b);i++) + + +#pragma region 建立带头结点的链表 + +typedef struct LNode { + ElemType data; + struct LNode* next; +}LNode, * LinkList; + +//初始化链表 +bool InitList(LinkList& L) { + //分配一个头结点 + L = (LNode*)malloc(sizeof(LNode)); + //内存不足,分配失败 + if (L == NULL) { + return false; + } + //头结点之后暂时还没有节点 + L->next = NULL; + return true; +} + + +//判断是否为空 +bool IsEmpty(LinkList L) { + return ((L->next) == NULL); +} + +//使用尾插法建表 +LinkList CreatList(vector data) { + if (data.size() < 1) { + return NULL; + } + //头结点 + LNode* head = (LinkList)malloc(sizeof(LNode)); + head->data = NULL; + head->next = NULL; + LinkList p = head; + _for(i, 0, data.size()) { + LNode* s = (LinkList)malloc(sizeof(LNode)); + s->data = data[i]; + s->next = NULL; + p->next = s; + p = s; + } + return head; +} +//输出链表 +void PrintList(LinkList list) { + while (list != NULL) { + printf("%d ", list->data); + list = list->next; + } + printf("\n"); +} + +#pragma endregion + + +//P40.3 +void ReversePrint(LinkList L) { + if (L->next != NULL) { + ReversePrint(L->next); + } + cout << L->data<<" "; +} + + +int main() +{ + vector data{ 2,4,5,6,7,3,6,41 }; + LinkList head; + InitList(head); + head = CreatList(data); + PrintList(head->next); + ReversePrint(head->next); + return 0; +} diff --git a/线性表/链式实现大题/P40.3/P40.3.sln b/线性表/链式实现大题/P40.3/P40.3.sln new file mode 100644 index 0000000..0163fd9 --- /dev/null +++ b/线性表/链式实现大题/P40.3/P40.3.sln @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.30804.86 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "P40.3", "P40.3.vcxproj", "{B2ECE814-0B47-448D-934C-C8EC0116E7B1}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {B2ECE814-0B47-448D-934C-C8EC0116E7B1}.Debug|x64.ActiveCfg = Debug|x64 + {B2ECE814-0B47-448D-934C-C8EC0116E7B1}.Debug|x64.Build.0 = Debug|x64 + {B2ECE814-0B47-448D-934C-C8EC0116E7B1}.Debug|x86.ActiveCfg = Debug|Win32 + {B2ECE814-0B47-448D-934C-C8EC0116E7B1}.Debug|x86.Build.0 = Debug|Win32 + {B2ECE814-0B47-448D-934C-C8EC0116E7B1}.Release|x64.ActiveCfg = Release|x64 + {B2ECE814-0B47-448D-934C-C8EC0116E7B1}.Release|x64.Build.0 = Release|x64 + {B2ECE814-0B47-448D-934C-C8EC0116E7B1}.Release|x86.ActiveCfg = Release|Win32 + {B2ECE814-0B47-448D-934C-C8EC0116E7B1}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {6E3E5E65-9B5F-49A5-A975-A21403A19A30} + EndGlobalSection +EndGlobal diff --git a/线性表/链式实现大题/P40.3/P40.3.vcxproj b/线性表/链式实现大题/P40.3/P40.3.vcxproj new file mode 100644 index 0000000..6ae2508 --- /dev/null +++ b/线性表/链式实现大题/P40.3/P40.3.vcxproj @@ -0,0 +1,147 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 16.0 + Win32Proj + {b2ece814-0b47-448d-934c-c8ec0116e7b1} + P403 + 10.0 + + + + Application + true + v142 + Unicode + + + Application + false + v142 + true + Unicode + + + Application + true + v142 + Unicode + + + Application + false + v142 + true + Unicode + + + + + + + + + + + + + + + + + + + + + true + + + false + + + true + + + false + + + + Level3 + true + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + true + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + Level3 + true + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + + + + + \ No newline at end of file diff --git a/线性表/链式实现大题/P40.3/P40.3.vcxproj.filters b/线性表/链式实现大题/P40.3/P40.3.vcxproj.filters new file mode 100644 index 0000000..4413c78 --- /dev/null +++ b/线性表/链式实现大题/P40.3/P40.3.vcxproj.filters @@ -0,0 +1,22 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Source Files + + + \ No newline at end of file diff --git a/线性表/链式实现大题/P40.3/P40.3.vcxproj.user b/线性表/链式实现大题/P40.3/P40.3.vcxproj.user new file mode 100644 index 0000000..88a5509 --- /dev/null +++ b/线性表/链式实现大题/P40.3/P40.3.vcxproj.user @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/线性表/链式实现大题/P40.4/.vs/P40.4/v16/.suo b/线性表/链式实现大题/P40.4/.vs/P40.4/v16/.suo new file mode 100644 index 0000000..ac6e7c8 Binary files /dev/null and b/线性表/链式实现大题/P40.4/.vs/P40.4/v16/.suo differ diff --git a/线性表/链式实现大题/P40.4/.vs/P40.4/v16/Browse.VC.db b/线性表/链式实现大题/P40.4/.vs/P40.4/v16/Browse.VC.db new file mode 100644 index 0000000..7d63307 Binary files /dev/null and b/线性表/链式实现大题/P40.4/.vs/P40.4/v16/Browse.VC.db differ diff --git a/线性表/链式实现大题/P40.4/.vs/P40.4/v16/ipch/AutoPCH/a9dddb64764e7c50/P40.4.ipch b/线性表/链式实现大题/P40.4/.vs/P40.4/v16/ipch/AutoPCH/a9dddb64764e7c50/P40.4.ipch new file mode 100644 index 0000000..8fb11c9 Binary files /dev/null and b/线性表/链式实现大题/P40.4/.vs/P40.4/v16/ipch/AutoPCH/a9dddb64764e7c50/P40.4.ipch differ diff --git a/线性表/链式实现大题/P40.4/Debug/P40.4.exe b/线性表/链式实现大题/P40.4/Debug/P40.4.exe new file mode 100644 index 0000000..aa08adc Binary files /dev/null and b/线性表/链式实现大题/P40.4/Debug/P40.4.exe differ diff --git a/线性表/链式实现大题/P40.4/Debug/P40.4.exe.recipe b/线性表/链式实现大题/P40.4/Debug/P40.4.exe.recipe new file mode 100644 index 0000000..961bb65 --- /dev/null +++ b/线性表/链式实现大题/P40.4/Debug/P40.4.exe.recipe @@ -0,0 +1,11 @@ + + + + + D:\college\code\C(C++)_CODE\考研数据结构\链式实现大题\P40.4\Debug\P40.4.exe + + + + + + \ No newline at end of file diff --git a/线性表/链式实现大题/P40.4/Debug/P40.4.ilk b/线性表/链式实现大题/P40.4/Debug/P40.4.ilk new file mode 100644 index 0000000..2d9cd4b Binary files /dev/null and b/线性表/链式实现大题/P40.4/Debug/P40.4.ilk differ diff --git a/线性表/链式实现大题/P40.4/Debug/P40.4.log b/线性表/链式实现大题/P40.4/Debug/P40.4.log new file mode 100644 index 0000000..019a359 --- /dev/null +++ b/线性表/链式实现大题/P40.4/Debug/P40.4.log @@ -0,0 +1,3 @@ + P40.4.cpp +D:\college\code\C(C++)_CODE\考研数据结构\链式实现大题\P40.4\P40.4.cpp(47,2): warning C4018: '<': signed/unsigned mismatch + P40.4.vcxproj -> D:\college\code\C(C++)_CODE\考研数据结构\链式实现大题\P40.4\Debug\P40.4.exe diff --git a/线性表/链式实现大题/P40.4/Debug/P40.4.obj b/线性表/链式实现大题/P40.4/Debug/P40.4.obj new file mode 100644 index 0000000..5a4b65b Binary files /dev/null and b/线性表/链式实现大题/P40.4/Debug/P40.4.obj differ diff --git a/线性表/链式实现大题/P40.4/Debug/P40.4.pdb b/线性表/链式实现大题/P40.4/Debug/P40.4.pdb new file mode 100644 index 0000000..95915a0 Binary files /dev/null and b/线性表/链式实现大题/P40.4/Debug/P40.4.pdb differ diff --git a/线性表/链式实现大题/P40.4/Debug/P40.4.tlog/CL.command.1.tlog b/线性表/链式实现大题/P40.4/Debug/P40.4.tlog/CL.command.1.tlog new file mode 100644 index 0000000..02e8fc8 Binary files /dev/null and b/线性表/链式实现大题/P40.4/Debug/P40.4.tlog/CL.command.1.tlog differ diff --git a/线性表/链式实现大题/P40.4/Debug/P40.4.tlog/CL.read.1.tlog b/线性表/链式实现大题/P40.4/Debug/P40.4.tlog/CL.read.1.tlog new file mode 100644 index 0000000..63a7e13 Binary files /dev/null and b/线性表/链式实现大题/P40.4/Debug/P40.4.tlog/CL.read.1.tlog differ diff --git a/线性表/链式实现大题/P40.4/Debug/P40.4.tlog/CL.write.1.tlog b/线性表/链式实现大题/P40.4/Debug/P40.4.tlog/CL.write.1.tlog new file mode 100644 index 0000000..52596ac Binary files /dev/null and b/线性表/链式实现大题/P40.4/Debug/P40.4.tlog/CL.write.1.tlog differ diff --git a/线性表/链式实现大题/P40.4/Debug/P40.4.tlog/P40.4.lastbuildstate b/线性表/链式实现大题/P40.4/Debug/P40.4.tlog/P40.4.lastbuildstate new file mode 100644 index 0000000..a04cfb2 --- /dev/null +++ b/线性表/链式实现大题/P40.4/Debug/P40.4.tlog/P40.4.lastbuildstate @@ -0,0 +1,2 @@ +PlatformToolSet=v142:VCToolArchitecture=Native32Bit:VCToolsVersion=14.28.29333:TargetPlatformVersion=10.0.18362.0: +Debug|Win32|D:\college\code\C(C++)_CODE\考研数据结构\链式实现大题\P40.4\| diff --git a/线性表/链式实现大题/P40.4/Debug/P40.4.tlog/link.command.1.tlog b/线性表/链式实现大题/P40.4/Debug/P40.4.tlog/link.command.1.tlog new file mode 100644 index 0000000..9a2626e Binary files /dev/null and b/线性表/链式实现大题/P40.4/Debug/P40.4.tlog/link.command.1.tlog differ diff --git a/线性表/链式实现大题/P40.4/Debug/P40.4.tlog/link.read.1.tlog b/线性表/链式实现大题/P40.4/Debug/P40.4.tlog/link.read.1.tlog new file mode 100644 index 0000000..1646144 Binary files /dev/null and b/线性表/链式实现大题/P40.4/Debug/P40.4.tlog/link.read.1.tlog differ diff --git a/线性表/链式实现大题/P40.4/Debug/P40.4.tlog/link.write.1.tlog b/线性表/链式实现大题/P40.4/Debug/P40.4.tlog/link.write.1.tlog new file mode 100644 index 0000000..fa9e7a9 Binary files /dev/null and b/线性表/链式实现大题/P40.4/Debug/P40.4.tlog/link.write.1.tlog differ diff --git a/线性表/链式实现大题/P40.4/Debug/P40.4.vcxproj.FileListAbsolute.txt b/线性表/链式实现大题/P40.4/Debug/P40.4.vcxproj.FileListAbsolute.txt new file mode 100644 index 0000000..174a565 --- /dev/null +++ b/线性表/链式实现大题/P40.4/Debug/P40.4.vcxproj.FileListAbsolute.txt @@ -0,0 +1,2 @@ +D:\college\code\C(C++)_CODE\考研数据结构\链式实现大题\P40.4\Debug\P40.4.exe +D:\college\code\C(C++)_CODE\考研数据结构\链式实现大题\P40.4\Debug\P40.4.pdb diff --git a/线性表/链式实现大题/P40.4/Debug/vc142.idb b/线性表/链式实现大题/P40.4/Debug/vc142.idb new file mode 100644 index 0000000..6c7ab84 Binary files /dev/null and b/线性表/链式实现大题/P40.4/Debug/vc142.idb differ diff --git a/线性表/链式实现大题/P40.4/Debug/vc142.pdb b/线性表/链式实现大题/P40.4/Debug/vc142.pdb new file mode 100644 index 0000000..f3a70da Binary files /dev/null and b/线性表/链式实现大题/P40.4/Debug/vc142.pdb differ diff --git a/线性表/链式实现大题/P40.4/P40.4.cpp b/线性表/链式实现大题/P40.4/P40.4.cpp new file mode 100644 index 0000000..4b40b44 --- /dev/null +++ b/线性表/链式实现大题/P40.4/P40.4.cpp @@ -0,0 +1,101 @@ +#include +#include +using namespace std; + +//P40.4 +//试编写在带头结点的单链表中删除一个最小值结点的高效算法(假设最小值结点是唯一的) +#define ElemType int +#define _for(i,a,b) for(int i=(a);i<(b);i++) +#define INF 0x3f3f3f3f + +#pragma region 建立带头结点的链表 + +typedef struct LNode { + ElemType data; + struct LNode* next; +}LNode, * LinkList; + +//初始化链表 +bool InitList(LinkList& L) { + //分配一个头结点 + L = (LNode*)malloc(sizeof(LNode)); + //内存不足,分配失败 + if (L == NULL) { + return false; + } + //头结点之后暂时还没有节点 + L->next = NULL; + return true; +} + + +//判断是否为空 +bool IsEmpty(LinkList L) { + return ((L->next) == NULL); +} + +//使用尾插法建表 +LinkList CreatList(vector data) { + if (data.size() < 1) { + return NULL; + } + //头结点 + LNode* head = (LinkList)malloc(sizeof(LNode)); + head->data = NULL; + head->next = NULL; + LinkList p = head; + _for(i, 0, data.size()) { + LNode* s = (LinkList)malloc(sizeof(LNode)); + s->data = data[i]; + s->next = NULL; + p->next = s; + p = s; + } + return head; +} +//输出链表 +void PrintList(LinkList list) { + list = list->next; + while (list != NULL) { + printf("%d ", list->data); + list = list->next; + } + printf("\n"); +} + +#pragma endregion + + +//P40.4 +void DelMinNode(LinkList& head) { + LNode* p = head->next; + LNode* q = head; + LNode* Minq = q, * Minp = p; + while (p != NULL) { + if (p->data < Minp->data) { + Minp = p; + Minq = q; + } + else { + q = p; + p = p->next; + } + } + LNode* X = Minp; + Minq->next = Minp->next; + Minp = Minp->next; + delete X; +} + + +int main() +{ + vector data{ 3,4,6,8,1,3,9,5 }; + LinkList head; + InitList(head); + head = CreatList(data); + PrintList(head); + DelMinNode(head); + PrintList(head); + return 0; +} diff --git a/线性表/链式实现大题/P40.4/P40.4.sln b/线性表/链式实现大题/P40.4/P40.4.sln new file mode 100644 index 0000000..4cb7706 --- /dev/null +++ b/线性表/链式实现大题/P40.4/P40.4.sln @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.30804.86 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "P40.4", "P40.4.vcxproj", "{55A5D37F-4534-476C-82DF-42F0130AE213}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {55A5D37F-4534-476C-82DF-42F0130AE213}.Debug|x64.ActiveCfg = Debug|x64 + {55A5D37F-4534-476C-82DF-42F0130AE213}.Debug|x64.Build.0 = Debug|x64 + {55A5D37F-4534-476C-82DF-42F0130AE213}.Debug|x86.ActiveCfg = Debug|Win32 + {55A5D37F-4534-476C-82DF-42F0130AE213}.Debug|x86.Build.0 = Debug|Win32 + {55A5D37F-4534-476C-82DF-42F0130AE213}.Release|x64.ActiveCfg = Release|x64 + {55A5D37F-4534-476C-82DF-42F0130AE213}.Release|x64.Build.0 = Release|x64 + {55A5D37F-4534-476C-82DF-42F0130AE213}.Release|x86.ActiveCfg = Release|Win32 + {55A5D37F-4534-476C-82DF-42F0130AE213}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {8C88FE1B-391D-498C-A87F-D6373F09E3BE} + EndGlobalSection +EndGlobal diff --git a/线性表/链式实现大题/P40.4/P40.4.vcxproj b/线性表/链式实现大题/P40.4/P40.4.vcxproj new file mode 100644 index 0000000..0ed7a78 --- /dev/null +++ b/线性表/链式实现大题/P40.4/P40.4.vcxproj @@ -0,0 +1,147 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 16.0 + Win32Proj + {55a5d37f-4534-476c-82df-42f0130ae213} + P404 + 10.0 + + + + Application + true + v142 + Unicode + + + Application + false + v142 + true + Unicode + + + Application + true + v142 + Unicode + + + Application + false + v142 + true + Unicode + + + + + + + + + + + + + + + + + + + + + true + + + false + + + true + + + false + + + + Level3 + true + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + true + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + Level3 + true + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + + + + + \ No newline at end of file diff --git a/线性表/链式实现大题/P40.4/P40.4.vcxproj.filters b/线性表/链式实现大题/P40.4/P40.4.vcxproj.filters new file mode 100644 index 0000000..eb25960 --- /dev/null +++ b/线性表/链式实现大题/P40.4/P40.4.vcxproj.filters @@ -0,0 +1,22 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Source Files + + + \ No newline at end of file diff --git a/线性表/链式实现大题/P40.4/P40.4.vcxproj.user b/线性表/链式实现大题/P40.4/P40.4.vcxproj.user new file mode 100644 index 0000000..88a5509 --- /dev/null +++ b/线性表/链式实现大题/P40.4/P40.4.vcxproj.user @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/线性表/链式实现大题/P40.5/.vs/P40.5/v16/.suo b/线性表/链式实现大题/P40.5/.vs/P40.5/v16/.suo new file mode 100644 index 0000000..680304b Binary files /dev/null and b/线性表/链式实现大题/P40.5/.vs/P40.5/v16/.suo differ diff --git a/线性表/链式实现大题/P40.5/.vs/P40.5/v16/Browse.VC.db b/线性表/链式实现大题/P40.5/.vs/P40.5/v16/Browse.VC.db new file mode 100644 index 0000000..777338a Binary files /dev/null and b/线性表/链式实现大题/P40.5/.vs/P40.5/v16/Browse.VC.db differ diff --git a/线性表/链式实现大题/P40.5/.vs/P40.5/v16/ipch/AutoPCH/8d2d9d3300774620/P40.5.ipch b/线性表/链式实现大题/P40.5/.vs/P40.5/v16/ipch/AutoPCH/8d2d9d3300774620/P40.5.ipch new file mode 100644 index 0000000..52b94da Binary files /dev/null and b/线性表/链式实现大题/P40.5/.vs/P40.5/v16/ipch/AutoPCH/8d2d9d3300774620/P40.5.ipch differ diff --git a/线性表/链式实现大题/P40.5/Debug/P40.5.exe b/线性表/链式实现大题/P40.5/Debug/P40.5.exe new file mode 100644 index 0000000..0fe0234 Binary files /dev/null and b/线性表/链式实现大题/P40.5/Debug/P40.5.exe differ diff --git a/线性表/链式实现大题/P40.5/Debug/P40.5.exe.recipe b/线性表/链式实现大题/P40.5/Debug/P40.5.exe.recipe new file mode 100644 index 0000000..ef602a0 --- /dev/null +++ b/线性表/链式实现大题/P40.5/Debug/P40.5.exe.recipe @@ -0,0 +1,11 @@ + + + + + D:\college\code\C(C++)_CODE\考研数据结构\链式实现大题\P40.5\Debug\P40.5.exe + + + + + + \ No newline at end of file diff --git a/线性表/链式实现大题/P40.5/Debug/P40.5.ilk b/线性表/链式实现大题/P40.5/Debug/P40.5.ilk new file mode 100644 index 0000000..d470e68 Binary files /dev/null and b/线性表/链式实现大题/P40.5/Debug/P40.5.ilk differ diff --git a/线性表/链式实现大题/P40.5/Debug/P40.5.log b/线性表/链式实现大题/P40.5/Debug/P40.5.log new file mode 100644 index 0000000..d4b0a87 --- /dev/null +++ b/线性表/链式实现大题/P40.5/Debug/P40.5.log @@ -0,0 +1,3 @@ + P40.5.cpp +D:\college\code\C(C++)_CODE\考研数据结构\链式实现大题\P40.5\P40.5.cpp(47,2): warning C4018: '<': signed/unsigned mismatch + P40.5.vcxproj -> D:\college\code\C(C++)_CODE\考研数据结构\链式实现大题\P40.5\Debug\P40.5.exe diff --git a/线性表/链式实现大题/P40.5/Debug/P40.5.obj b/线性表/链式实现大题/P40.5/Debug/P40.5.obj new file mode 100644 index 0000000..87dc121 Binary files /dev/null and b/线性表/链式实现大题/P40.5/Debug/P40.5.obj differ diff --git a/线性表/链式实现大题/P40.5/Debug/P40.5.pdb b/线性表/链式实现大题/P40.5/Debug/P40.5.pdb new file mode 100644 index 0000000..13256ff Binary files /dev/null and b/线性表/链式实现大题/P40.5/Debug/P40.5.pdb differ diff --git a/线性表/链式实现大题/P40.5/Debug/P40.5.tlog/CL.command.1.tlog b/线性表/链式实现大题/P40.5/Debug/P40.5.tlog/CL.command.1.tlog new file mode 100644 index 0000000..e8de334 Binary files /dev/null and b/线性表/链式实现大题/P40.5/Debug/P40.5.tlog/CL.command.1.tlog differ diff --git a/线性表/链式实现大题/P40.5/Debug/P40.5.tlog/CL.read.1.tlog b/线性表/链式实现大题/P40.5/Debug/P40.5.tlog/CL.read.1.tlog new file mode 100644 index 0000000..458de50 Binary files /dev/null and b/线性表/链式实现大题/P40.5/Debug/P40.5.tlog/CL.read.1.tlog differ diff --git a/线性表/链式实现大题/P40.5/Debug/P40.5.tlog/CL.write.1.tlog b/线性表/链式实现大题/P40.5/Debug/P40.5.tlog/CL.write.1.tlog new file mode 100644 index 0000000..c6372b4 Binary files /dev/null and b/线性表/链式实现大题/P40.5/Debug/P40.5.tlog/CL.write.1.tlog differ diff --git a/线性表/链式实现大题/P40.5/Debug/P40.5.tlog/P40.5.lastbuildstate b/线性表/链式实现大题/P40.5/Debug/P40.5.tlog/P40.5.lastbuildstate new file mode 100644 index 0000000..1a79269 --- /dev/null +++ b/线性表/链式实现大题/P40.5/Debug/P40.5.tlog/P40.5.lastbuildstate @@ -0,0 +1,2 @@ +PlatformToolSet=v142:VCToolArchitecture=Native32Bit:VCToolsVersion=14.28.29333:TargetPlatformVersion=10.0.18362.0: +Debug|Win32|D:\college\code\C(C++)_CODE\考研数据结构\链式实现大题\P40.5\| diff --git a/线性表/链式实现大题/P40.5/Debug/P40.5.tlog/link.command.1.tlog b/线性表/链式实现大题/P40.5/Debug/P40.5.tlog/link.command.1.tlog new file mode 100644 index 0000000..9eb563d Binary files /dev/null and b/线性表/链式实现大题/P40.5/Debug/P40.5.tlog/link.command.1.tlog differ diff --git a/线性表/链式实现大题/P40.5/Debug/P40.5.tlog/link.read.1.tlog b/线性表/链式实现大题/P40.5/Debug/P40.5.tlog/link.read.1.tlog new file mode 100644 index 0000000..020d8b6 Binary files /dev/null and b/线性表/链式实现大题/P40.5/Debug/P40.5.tlog/link.read.1.tlog differ diff --git a/线性表/链式实现大题/P40.5/Debug/P40.5.tlog/link.write.1.tlog b/线性表/链式实现大题/P40.5/Debug/P40.5.tlog/link.write.1.tlog new file mode 100644 index 0000000..80c14d5 Binary files /dev/null and b/线性表/链式实现大题/P40.5/Debug/P40.5.tlog/link.write.1.tlog differ diff --git a/线性表/链式实现大题/P40.5/Debug/P40.5.vcxproj.FileListAbsolute.txt b/线性表/链式实现大题/P40.5/Debug/P40.5.vcxproj.FileListAbsolute.txt new file mode 100644 index 0000000..8be9f7e --- /dev/null +++ b/线性表/链式实现大题/P40.5/Debug/P40.5.vcxproj.FileListAbsolute.txt @@ -0,0 +1,2 @@ +D:\college\code\C(C++)_CODE\考研数据结构\链式实现大题\P40.5\Debug\P40.5.exe +D:\college\code\C(C++)_CODE\考研数据结构\链式实现大题\P40.5\Debug\P40.5.pdb diff --git a/线性表/链式实现大题/P40.5/Debug/vc142.idb b/线性表/链式实现大题/P40.5/Debug/vc142.idb new file mode 100644 index 0000000..3fbd94f Binary files /dev/null and b/线性表/链式实现大题/P40.5/Debug/vc142.idb differ diff --git a/线性表/链式实现大题/P40.5/Debug/vc142.pdb b/线性表/链式实现大题/P40.5/Debug/vc142.pdb new file mode 100644 index 0000000..e0f785a Binary files /dev/null and b/线性表/链式实现大题/P40.5/Debug/vc142.pdb differ diff --git a/线性表/链式实现大题/P40.5/P40.5.cpp b/线性表/链式实现大题/P40.5/P40.5.cpp new file mode 100644 index 0000000..8158ecd --- /dev/null +++ b/线性表/链式实现大题/P40.5/P40.5.cpp @@ -0,0 +1,93 @@ +#include +#include +using namespace std; + +//P40.5 +//试编写算法将带头结点的单链表就地逆置,所谓“就地”是指辅助空间复杂度为O(1) +#define ElemType int +#define _for(i,a,b) for(int i=(a);i<(b);i++) +#define INF 0x3f3f3f3f + +#pragma region 建立带头结点的链表 + +typedef struct LNode { + ElemType data; + struct LNode* next; +}LNode, * LinkList; + +//初始化链表 +bool InitList(LinkList& L) { + //分配一个头结点 + L = (LNode*)malloc(sizeof(LNode)); + //内存不足,分配失败 + if (L == NULL) { + return false; + } + //头结点之后暂时还没有节点 + L->next = NULL; + return true; +} + + +//判断是否为空 +bool IsEmpty(LinkList L) { + return ((L->next) == NULL); +} + +//使用尾插法建表 +LinkList CreatList(vector data) { + if (data.size() < 1) { + return NULL; + } + //头结点 + LNode* head = (LinkList)malloc(sizeof(LNode)); + head->data = NULL; + head->next = NULL; + LinkList p = head; + _for(i, 0, data.size()) { + LNode* s = (LinkList)malloc(sizeof(LNode)); + s->data = data[i]; + s->next = NULL; + p->next = s; + p = s; + } + return head; +} +//输出链表 +void PrintList(LinkList list) { + list = list->next; + while (list != NULL) { + printf("%d ", list->data); + list = list->next; + } + printf("\n"); +} + +#pragma endregion + + +//P40.5 +//算法思想:将指针反过来 +void ReverseList(LinkList& head) { + LNode* pre, * p = head->next, * r = p->next; + p->next = NULL; + while (r != NULL) { + pre = p; + p = r; + r = r->next; + p->next = pre; + } + head->next = p; +} + +int main() +{ + vector data{ 3,4,6,8,1,3,9,5 }; + LinkList head; + InitList(head); + head = CreatList(data); + PrintList(head); + ReverseList(head); + PrintList(head); + return 0; +} diff --git a/线性表/链式实现大题/P40.5/P40.5.sln b/线性表/链式实现大题/P40.5/P40.5.sln new file mode 100644 index 0000000..b6fe14d --- /dev/null +++ b/线性表/链式实现大题/P40.5/P40.5.sln @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.30804.86 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "P40.5", "P40.5.vcxproj", "{9653E217-6282-4A3E-A81A-1B7375BA1F79}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {9653E217-6282-4A3E-A81A-1B7375BA1F79}.Debug|x64.ActiveCfg = Debug|x64 + {9653E217-6282-4A3E-A81A-1B7375BA1F79}.Debug|x64.Build.0 = Debug|x64 + {9653E217-6282-4A3E-A81A-1B7375BA1F79}.Debug|x86.ActiveCfg = Debug|Win32 + {9653E217-6282-4A3E-A81A-1B7375BA1F79}.Debug|x86.Build.0 = Debug|Win32 + {9653E217-6282-4A3E-A81A-1B7375BA1F79}.Release|x64.ActiveCfg = Release|x64 + {9653E217-6282-4A3E-A81A-1B7375BA1F79}.Release|x64.Build.0 = Release|x64 + {9653E217-6282-4A3E-A81A-1B7375BA1F79}.Release|x86.ActiveCfg = Release|Win32 + {9653E217-6282-4A3E-A81A-1B7375BA1F79}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {6882503E-A116-4944-B4A5-06C87338E7C0} + EndGlobalSection +EndGlobal diff --git a/线性表/链式实现大题/P40.5/P40.5.vcxproj b/线性表/链式实现大题/P40.5/P40.5.vcxproj new file mode 100644 index 0000000..fcaf504 --- /dev/null +++ b/线性表/链式实现大题/P40.5/P40.5.vcxproj @@ -0,0 +1,147 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 16.0 + Win32Proj + {9653e217-6282-4a3e-a81a-1b7375ba1f79} + P405 + 10.0 + + + + Application + true + v142 + Unicode + + + Application + false + v142 + true + Unicode + + + Application + true + v142 + Unicode + + + Application + false + v142 + true + Unicode + + + + + + + + + + + + + + + + + + + + + true + + + false + + + true + + + false + + + + Level3 + true + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + true + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + Level3 + true + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + + + + + \ No newline at end of file diff --git a/线性表/链式实现大题/P40.5/P40.5.vcxproj.filters b/线性表/链式实现大题/P40.5/P40.5.vcxproj.filters new file mode 100644 index 0000000..3ac95fa --- /dev/null +++ b/线性表/链式实现大题/P40.5/P40.5.vcxproj.filters @@ -0,0 +1,22 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Source Files + + + \ No newline at end of file diff --git a/线性表/链式实现大题/P40.5/P40.5.vcxproj.user b/线性表/链式实现大题/P40.5/P40.5.vcxproj.user new file mode 100644 index 0000000..88a5509 --- /dev/null +++ b/线性表/链式实现大题/P40.5/P40.5.vcxproj.user @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/线性表/顺序实现大题/.vs/第二章大题/v16/.suo b/线性表/顺序实现大题/.vs/第二章大题/v16/.suo new file mode 100644 index 0000000..9b947ec Binary files /dev/null and b/线性表/顺序实现大题/.vs/第二章大题/v16/.suo differ diff --git a/线性表/顺序实现大题/.vs/第二章大题/v16/Browse.VC.db b/线性表/顺序实现大题/.vs/第二章大题/v16/Browse.VC.db new file mode 100644 index 0000000..980ec19 Binary files /dev/null and b/线性表/顺序实现大题/.vs/第二章大题/v16/Browse.VC.db differ diff --git a/线性表/顺序实现大题/.vs/第二章大题/v16/ipch/AutoPCH/359a030b5e48dafa/1.ipch b/线性表/顺序实现大题/.vs/第二章大题/v16/ipch/AutoPCH/359a030b5e48dafa/1.ipch new file mode 100644 index 0000000..f8ab792 Binary files /dev/null and b/线性表/顺序实现大题/.vs/第二章大题/v16/ipch/AutoPCH/359a030b5e48dafa/1.ipch differ diff --git a/线性表/顺序实现大题/.vs/第二章大题/v16/ipch/AutoPCH/419ffd8804f5c188/线性表链式表示大题.ipch b/线性表/顺序实现大题/.vs/第二章大题/v16/ipch/AutoPCH/419ffd8804f5c188/线性表链式表示大题.ipch new file mode 100644 index 0000000..823b6b9 Binary files /dev/null and b/线性表/顺序实现大题/.vs/第二章大题/v16/ipch/AutoPCH/419ffd8804f5c188/线性表链式表示大题.ipch differ diff --git a/线性表/顺序实现大题/.vs/第二章大题/v16/ipch/AutoPCH/82f20dbaecb59d30/线性表顺序表示大题.ipch b/线性表/顺序实现大题/.vs/第二章大题/v16/ipch/AutoPCH/82f20dbaecb59d30/线性表顺序表示大题.ipch new file mode 100644 index 0000000..045557b Binary files /dev/null and b/线性表/顺序实现大题/.vs/第二章大题/v16/ipch/AutoPCH/82f20dbaecb59d30/线性表顺序表示大题.ipch differ diff --git a/线性表/顺序实现大题/.vs/第二章大题/v16/ipch/AutoPCH/d5e39f4a82e55337/顺序表大题.ipch b/线性表/顺序实现大题/.vs/第二章大题/v16/ipch/AutoPCH/d5e39f4a82e55337/顺序表大题.ipch new file mode 100644 index 0000000..ff3f82b Binary files /dev/null and b/线性表/顺序实现大题/.vs/第二章大题/v16/ipch/AutoPCH/d5e39f4a82e55337/顺序表大题.ipch differ diff --git a/线性表/顺序实现大题/.vs/第二章大题/v16/ipch/AutoPCH/f9b4abc798f4ae94/线性表顺序表示大题.ipch b/线性表/顺序实现大题/.vs/第二章大题/v16/ipch/AutoPCH/f9b4abc798f4ae94/线性表顺序表示大题.ipch new file mode 100644 index 0000000..a1dd9c7 Binary files /dev/null and b/线性表/顺序实现大题/.vs/第二章大题/v16/ipch/AutoPCH/f9b4abc798f4ae94/线性表顺序表示大题.ipch differ diff --git a/线性表/顺序实现大题/1.cpp b/线性表/顺序实现大题/1.cpp new file mode 100644 index 0000000..2b35270 --- /dev/null +++ b/线性表/顺序实现大题/1.cpp @@ -0,0 +1,72 @@ +/** +*作 者:Ruvik +*CSND地址:https://blog.csdn.net/ruvikm +**GitHub :https://github.com/Ruvikm + +// .-~~~~~~~~~-._ _.-~~~~~~~~~-. +// __.' ~. .~ `.__ +// .'// \./ \\`. +// .'// | \\`. +// .'// .-~"""""""~~~~-._ | _,-~~~~"""""""~-. \\`. +// .'//.-" `-. | .-' "-.\\`. +// .'//______.============-.. \ | / ..-============.______\\`. +//.'______________________________\|/______________________________`. +**/ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +using namespace std; + +//P40.1 + +#define ElemType int +#define _for(i,a,b) for(int i=(a);i<=(b);i++) + +typedef struct LNode { + ElemType data; + struct LNode* next; +}LNode, * LinkList; + +void DeleteXNode(LinkList linklist, ElemType X) { +} + +LinkList CreatList(int len, vector data) { + if (len < 1) { + return NULL; + } + LinkList head = (LinkList)malloc(sizeof(LNode)); + LinkList point = head; + head->data = data[0]; + head->next = NULL; + _for(i, 1, data.size()) { + LNode* s = (LNode*)malloc(sizeof(LNode)); + s->data = data[i]; + s->next = NULL; + point->next = s; + point = s; + } +} + +void PrintList(LinkList list) { + while (list->next != NULL) { + printf("%d", list->data); + list = list->next; + } +} + +int main() +{ + vector data{ 2,4,6,1,5,3,7,41 }; + LinkList list; + list = CreatList(8, data); + PrintList(list); + return 0; +} \ No newline at end of file diff --git a/线性表/顺序实现大题/19.1.vcxproj b/线性表/顺序实现大题/19.1.vcxproj new file mode 100644 index 0000000..e4bac70 --- /dev/null +++ b/线性表/顺序实现大题/19.1.vcxproj @@ -0,0 +1,148 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 16.0 + Win32Proj + {92019639-0363-4f6e-99d9-36b951eef6a0} + My191 + 10.0 + 第二章大题 + + + + Application + true + v142 + Unicode + + + Application + false + v142 + true + Unicode + + + Application + true + v142 + Unicode + + + Application + false + v142 + true + Unicode + + + + + + + + + + + + + + + + + + + + + true + + + false + + + true + + + false + + + + Level3 + true + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + true + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + Level3 + true + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + + + + + \ No newline at end of file diff --git a/线性表/顺序实现大题/19.1.vcxproj.filters b/线性表/顺序实现大题/19.1.vcxproj.filters new file mode 100644 index 0000000..d19c104 --- /dev/null +++ b/线性表/顺序实现大题/19.1.vcxproj.filters @@ -0,0 +1,22 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + 源文件 + + + \ No newline at end of file diff --git a/线性表/顺序实现大题/19.1.vcxproj.user b/线性表/顺序实现大题/19.1.vcxproj.user new file mode 100644 index 0000000..88a5509 --- /dev/null +++ b/线性表/顺序实现大题/19.1.vcxproj.user @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/线性表/顺序实现大题/Debug/1.obj b/线性表/顺序实现大题/Debug/1.obj new file mode 100644 index 0000000..f9bf357 Binary files /dev/null and b/线性表/顺序实现大题/Debug/1.obj differ diff --git a/线性表/顺序实现大题/Debug/19.1.exe.recipe b/线性表/顺序实现大题/Debug/19.1.exe.recipe new file mode 100644 index 0000000..e77f2c1 --- /dev/null +++ b/线性表/顺序实现大题/Debug/19.1.exe.recipe @@ -0,0 +1,7 @@ + + + E:\college\code\C(C++)_CODE\考研数据结构\19.1\Debug\19.1.exe + + + + \ No newline at end of file diff --git a/线性表/顺序实现大题/Debug/19.1.ilk b/线性表/顺序实现大题/Debug/19.1.ilk new file mode 100644 index 0000000..86afc81 Binary files /dev/null and b/线性表/顺序实现大题/Debug/19.1.ilk differ diff --git a/线性表/顺序实现大题/Debug/19.1.log b/线性表/顺序实现大题/Debug/19.1.log new file mode 100644 index 0000000..bd5e461 --- /dev/null +++ b/线性表/顺序实现大题/Debug/19.1.log @@ -0,0 +1,4 @@ +D:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Microsoft\VC\v160\Microsoft.CppBuild.targets(491,5): warning MSB8028: The intermediate directory (Debug\) contains files shared from another project (19.1.vcxproj, 19.二.vcxproj). This can lead to incorrect clean and rebuild behavior. + 线性表顺序表示大题.cpp +E:\college\code\C(C++)_CODE\考研数据结构\顺序实现大题\线性表顺序表示大题.cpp(324): warning C4715: 'FindMinNum': not all control paths return a value + 19.1.vcxproj -> E:\college\code\C(C++)_CODE\考研数据结构\顺序实现大题\Debug\第二章大题.exe diff --git a/线性表/顺序实现大题/Debug/19.1.obj b/线性表/顺序实现大题/Debug/19.1.obj new file mode 100644 index 0000000..366b31a Binary files /dev/null and b/线性表/顺序实现大题/Debug/19.1.obj differ diff --git a/线性表/顺序实现大题/Debug/19.1.tlog/19.1.lastbuildstate b/线性表/顺序实现大题/Debug/19.1.tlog/19.1.lastbuildstate new file mode 100644 index 0000000..8ead433 --- /dev/null +++ b/线性表/顺序实现大题/Debug/19.1.tlog/19.1.lastbuildstate @@ -0,0 +1,2 @@ +PlatformToolSet=v142:VCToolArchitecture=Native32Bit:VCToolsVersion=14.27.29110:TargetPlatformVersion=10.0.18362.0: +Debug|Win32|E:\college\code\C(C++)_CODE\考研数据结构\19.1\| diff --git a/线性表/顺序实现大题/Debug/19.1.tlog/CL.command.1.tlog b/线性表/顺序实现大题/Debug/19.1.tlog/CL.command.1.tlog new file mode 100644 index 0000000..3591e74 Binary files /dev/null and b/线性表/顺序实现大题/Debug/19.1.tlog/CL.command.1.tlog differ diff --git a/线性表/顺序实现大题/Debug/19.1.tlog/CL.read.1.tlog b/线性表/顺序实现大题/Debug/19.1.tlog/CL.read.1.tlog new file mode 100644 index 0000000..1acebb1 Binary files /dev/null and b/线性表/顺序实现大题/Debug/19.1.tlog/CL.read.1.tlog differ diff --git a/线性表/顺序实现大题/Debug/19.1.tlog/CL.write.1.tlog b/线性表/顺序实现大题/Debug/19.1.tlog/CL.write.1.tlog new file mode 100644 index 0000000..b0e1b8a Binary files /dev/null and b/线性表/顺序实现大题/Debug/19.1.tlog/CL.write.1.tlog differ diff --git a/线性表/顺序实现大题/Debug/19.1.tlog/link.command.1.tlog b/线性表/顺序实现大题/Debug/19.1.tlog/link.command.1.tlog new file mode 100644 index 0000000..6906958 Binary files /dev/null and b/线性表/顺序实现大题/Debug/19.1.tlog/link.command.1.tlog differ diff --git a/线性表/顺序实现大题/Debug/19.1.tlog/link.read.1.tlog b/线性表/顺序实现大题/Debug/19.1.tlog/link.read.1.tlog new file mode 100644 index 0000000..5d839ff Binary files /dev/null and b/线性表/顺序实现大题/Debug/19.1.tlog/link.read.1.tlog differ diff --git a/线性表/顺序实现大题/Debug/19.1.tlog/link.write.1.tlog b/线性表/顺序实现大题/Debug/19.1.tlog/link.write.1.tlog new file mode 100644 index 0000000..2576bea Binary files /dev/null and b/线性表/顺序实现大题/Debug/19.1.tlog/link.write.1.tlog differ diff --git a/线性表/顺序实现大题/Debug/19.1.vcxproj.FileListAbsolute.txt b/线性表/顺序实现大题/Debug/19.1.vcxproj.FileListAbsolute.txt new file mode 100644 index 0000000..269b478 --- /dev/null +++ b/线性表/顺序实现大题/Debug/19.1.vcxproj.FileListAbsolute.txt @@ -0,0 +1,4 @@ +E:\college\code\C(C++)_CODE\考研数据结构\19.1\Debug\19.二.exe +E:\college\code\C(C++)_CODE\考研数据结构\19.1\Debug\19.二.pdb +E:\college\code\C(C++)_CODE\考研数据结构\顺序实现大题\Debug\第二章大题.exe +E:\college\code\C(C++)_CODE\考研数据结构\顺序实现大题\Debug\第二章大题.pdb diff --git a/线性表/顺序实现大题/Debug/19.二.exe b/线性表/顺序实现大题/Debug/19.二.exe new file mode 100644 index 0000000..d33c241 Binary files /dev/null and b/线性表/顺序实现大题/Debug/19.二.exe differ diff --git a/线性表/顺序实现大题/Debug/19.二.exe.recipe b/线性表/顺序实现大题/Debug/19.二.exe.recipe new file mode 100644 index 0000000..af94fa7 --- /dev/null +++ b/线性表/顺序实现大题/Debug/19.二.exe.recipe @@ -0,0 +1,7 @@ + + + E:\college\code\C(C++)_CODE\考研数据结构\19.1\Debug\19.二.exe + + + + \ No newline at end of file diff --git a/线性表/顺序实现大题/Debug/19.二.ilk b/线性表/顺序实现大题/Debug/19.二.ilk new file mode 100644 index 0000000..9b5a43e Binary files /dev/null and b/线性表/顺序实现大题/Debug/19.二.ilk differ diff --git a/线性表/顺序实现大题/Debug/19.二.obj b/线性表/顺序实现大题/Debug/19.二.obj new file mode 100644 index 0000000..0549643 Binary files /dev/null and b/线性表/顺序实现大题/Debug/19.二.obj differ diff --git a/线性表/顺序实现大题/Debug/19.二.obj.enc b/线性表/顺序实现大题/Debug/19.二.obj.enc new file mode 100644 index 0000000..4f7b0f2 Binary files /dev/null and b/线性表/顺序实现大题/Debug/19.二.obj.enc differ diff --git a/线性表/顺序实现大题/Debug/19.二.pdb b/线性表/顺序实现大题/Debug/19.二.pdb new file mode 100644 index 0000000..46e1a67 Binary files /dev/null and b/线性表/顺序实现大题/Debug/19.二.pdb differ diff --git a/线性表/顺序实现大题/Debug/19.二.tlog/19.二.lastbuildstate b/线性表/顺序实现大题/Debug/19.二.tlog/19.二.lastbuildstate new file mode 100644 index 0000000..8ead433 --- /dev/null +++ b/线性表/顺序实现大题/Debug/19.二.tlog/19.二.lastbuildstate @@ -0,0 +1,2 @@ +PlatformToolSet=v142:VCToolArchitecture=Native32Bit:VCToolsVersion=14.27.29110:TargetPlatformVersion=10.0.18362.0: +Debug|Win32|E:\college\code\C(C++)_CODE\考研数据结构\19.1\| diff --git a/线性表/顺序实现大题/Debug/19.二.tlog/CL.command.1.tlog b/线性表/顺序实现大题/Debug/19.二.tlog/CL.command.1.tlog new file mode 100644 index 0000000..5e3d30a Binary files /dev/null and b/线性表/顺序实现大题/Debug/19.二.tlog/CL.command.1.tlog differ diff --git a/线性表/顺序实现大题/Debug/19.二.tlog/CL.read.1.tlog b/线性表/顺序实现大题/Debug/19.二.tlog/CL.read.1.tlog new file mode 100644 index 0000000..3552a03 Binary files /dev/null and b/线性表/顺序实现大题/Debug/19.二.tlog/CL.read.1.tlog differ diff --git a/线性表/顺序实现大题/Debug/19.二.tlog/CL.write.1.tlog b/线性表/顺序实现大题/Debug/19.二.tlog/CL.write.1.tlog new file mode 100644 index 0000000..915e52e Binary files /dev/null and b/线性表/顺序实现大题/Debug/19.二.tlog/CL.write.1.tlog differ diff --git a/线性表/顺序实现大题/Debug/19.二.tlog/link.command.1.tlog b/线性表/顺序实现大题/Debug/19.二.tlog/link.command.1.tlog new file mode 100644 index 0000000..e9bd169 Binary files /dev/null and b/线性表/顺序实现大题/Debug/19.二.tlog/link.command.1.tlog differ diff --git a/线性表/顺序实现大题/Debug/19.二.tlog/link.read.1.tlog b/线性表/顺序实现大题/Debug/19.二.tlog/link.read.1.tlog new file mode 100644 index 0000000..6dce118 Binary files /dev/null and b/线性表/顺序实现大题/Debug/19.二.tlog/link.read.1.tlog differ diff --git a/线性表/顺序实现大题/Debug/19.二.tlog/link.write.1.tlog b/线性表/顺序实现大题/Debug/19.二.tlog/link.write.1.tlog new file mode 100644 index 0000000..ca62bb4 Binary files /dev/null and b/线性表/顺序实现大题/Debug/19.二.tlog/link.write.1.tlog differ diff --git a/线性表/顺序实现大题/Debug/vc142.idb b/线性表/顺序实现大题/Debug/vc142.idb new file mode 100644 index 0000000..a8d32db Binary files /dev/null and b/线性表/顺序实现大题/Debug/vc142.idb differ diff --git a/线性表/顺序实现大题/Debug/vc142.pdb b/线性表/顺序实现大题/Debug/vc142.pdb new file mode 100644 index 0000000..11917ed Binary files /dev/null and b/线性表/顺序实现大题/Debug/vc142.pdb differ diff --git a/线性表/顺序实现大题/Debug/第二章大题.exe b/线性表/顺序实现大题/Debug/第二章大题.exe new file mode 100644 index 0000000..23e6130 Binary files /dev/null and b/线性表/顺序实现大题/Debug/第二章大题.exe differ diff --git a/线性表/顺序实现大题/Debug/第二章大题.exe.recipe b/线性表/顺序实现大题/Debug/第二章大题.exe.recipe new file mode 100644 index 0000000..4b6c60a --- /dev/null +++ b/线性表/顺序实现大题/Debug/第二章大题.exe.recipe @@ -0,0 +1,7 @@ + + + E:\college\code\C(C++)_CODE\考研数据结构\顺序实现大题\Debug\第二章大题.exe + + + + \ No newline at end of file diff --git a/线性表/顺序实现大题/Debug/第二章大题.ilk b/线性表/顺序实现大题/Debug/第二章大题.ilk new file mode 100644 index 0000000..50766d2 Binary files /dev/null and b/线性表/顺序实现大题/Debug/第二章大题.ilk differ diff --git a/线性表/顺序实现大题/Debug/第二章大题.pdb b/线性表/顺序实现大题/Debug/第二章大题.pdb new file mode 100644 index 0000000..262b079 Binary files /dev/null and b/线性表/顺序实现大题/Debug/第二章大题.pdb differ diff --git a/线性表/顺序实现大题/Debug/第二章大题.tlog/CL.command.1.tlog b/线性表/顺序实现大题/Debug/第二章大题.tlog/CL.command.1.tlog new file mode 100644 index 0000000..c678f86 Binary files /dev/null and b/线性表/顺序实现大题/Debug/第二章大题.tlog/CL.command.1.tlog differ diff --git a/线性表/顺序实现大题/Debug/第二章大题.tlog/CL.read.1.tlog b/线性表/顺序实现大题/Debug/第二章大题.tlog/CL.read.1.tlog new file mode 100644 index 0000000..31a0702 Binary files /dev/null and b/线性表/顺序实现大题/Debug/第二章大题.tlog/CL.read.1.tlog differ diff --git a/线性表/顺序实现大题/Debug/第二章大题.tlog/CL.write.1.tlog b/线性表/顺序实现大题/Debug/第二章大题.tlog/CL.write.1.tlog new file mode 100644 index 0000000..be89082 Binary files /dev/null and b/线性表/顺序实现大题/Debug/第二章大题.tlog/CL.write.1.tlog differ diff --git a/线性表/顺序实现大题/Debug/第二章大题.tlog/link.command.1.tlog b/线性表/顺序实现大题/Debug/第二章大题.tlog/link.command.1.tlog new file mode 100644 index 0000000..529c95a Binary files /dev/null and b/线性表/顺序实现大题/Debug/第二章大题.tlog/link.command.1.tlog differ diff --git a/线性表/顺序实现大题/Debug/第二章大题.tlog/link.read.1.tlog b/线性表/顺序实现大题/Debug/第二章大题.tlog/link.read.1.tlog new file mode 100644 index 0000000..a64ed5c Binary files /dev/null and b/线性表/顺序实现大题/Debug/第二章大题.tlog/link.read.1.tlog differ diff --git a/线性表/顺序实现大题/Debug/第二章大题.tlog/link.write.1.tlog b/线性表/顺序实现大题/Debug/第二章大题.tlog/link.write.1.tlog new file mode 100644 index 0000000..48fc4d4 Binary files /dev/null and b/线性表/顺序实现大题/Debug/第二章大题.tlog/link.write.1.tlog differ diff --git a/线性表/顺序实现大题/Debug/第二章大题.tlog/第二章大题.lastbuildstate b/线性表/顺序实现大题/Debug/第二章大题.tlog/第二章大题.lastbuildstate new file mode 100644 index 0000000..a39c921 --- /dev/null +++ b/线性表/顺序实现大题/Debug/第二章大题.tlog/第二章大题.lastbuildstate @@ -0,0 +1,2 @@ +PlatformToolSet=v142:VCToolArchitecture=Native32Bit:VCToolsVersion=14.27.29110:TargetPlatformVersion=10.0.18362.0: +Debug|Win32|E:\college\code\C(C++)_CODE\考研数据结构\顺序实现大题\| diff --git a/线性表/顺序实现大题/Debug/线性表顺序表示大题.obj b/线性表/顺序实现大题/Debug/线性表顺序表示大题.obj new file mode 100644 index 0000000..d450e32 Binary files /dev/null and b/线性表/顺序实现大题/Debug/线性表顺序表示大题.obj differ diff --git a/线性表/顺序实现大题/第二章大题.sln b/线性表/顺序实现大题/第二章大题.sln new file mode 100644 index 0000000..9b495c2 --- /dev/null +++ b/线性表/顺序实现大题/第二章大题.sln @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.30517.126 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "19.1", "19.1.vcxproj", "{92019639-0363-4F6E-99D9-36B951EEF6A0}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {92019639-0363-4F6E-99D9-36B951EEF6A0}.Debug|x64.ActiveCfg = Debug|x64 + {92019639-0363-4F6E-99D9-36B951EEF6A0}.Debug|x64.Build.0 = Debug|x64 + {92019639-0363-4F6E-99D9-36B951EEF6A0}.Debug|x86.ActiveCfg = Debug|Win32 + {92019639-0363-4F6E-99D9-36B951EEF6A0}.Debug|x86.Build.0 = Debug|Win32 + {92019639-0363-4F6E-99D9-36B951EEF6A0}.Release|x64.ActiveCfg = Release|x64 + {92019639-0363-4F6E-99D9-36B951EEF6A0}.Release|x64.Build.0 = Release|x64 + {92019639-0363-4F6E-99D9-36B951EEF6A0}.Release|x86.ActiveCfg = Release|Win32 + {92019639-0363-4F6E-99D9-36B951EEF6A0}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {D7AF6527-C4CA-4BFB-B7C6-0167D4E2AF43} + EndGlobalSection +EndGlobal diff --git a/线性表/顺序实现大题/线性表顺序表示大题.cpp b/线性表/顺序实现大题/线性表顺序表示大题.cpp new file mode 100644 index 0000000..1ffbe18 --- /dev/null +++ b/线性表/顺序实现大题/线性表顺序表示大题.cpp @@ -0,0 +1,343 @@ +#include +#include +#include + +using namespace std; + +#define MAX 30 +#define _for(i,a,b) for( int i=(a); i<(b); ++i) +#define _rep(i,a,b) for( int i=(a); i<=(b); ++i) + +typedef struct { + int data[MAX]; + int length; +}List; + +void swap(int* a, int* b) { + int t; + t = *a; + *a = *b; + *b = t; +} + +//给定一个List,传入List的大小,要逆转的起始位置 +void Reserve(List* list, int start, int end, int size) { + if (end <= start || end >= size) { + return; + } + int mid = (start + end) / 2; + _rep(i, 0, mid - start) { + swap(&list->data[start + i], &list->data[end - i]); + } + /* _for(i, 0, list->length) { + printf("%d ", list->data[i]); + }*/ +} + +//P19.1 +//从顺序表中删除具有最小值的元素(假设唯一)并由函数返回被删元素的值。空出的位 +//置由最后一个元素填补, 若顺序表为空则显示出错信息并退出运行 +int FindMin(List* list) +{ + if (!(*list).length) { + printf("Error!\n"); + return -1; + } + + int Min = 9999; + int point; + for (int i = 0; i < (*list).length; i++) + { + if ((*list).data[i] < Min) + { + Min = (*list).data[i]; + point = i; + } + } + (*list).data[point] = (*list).data[(*list).length - 1]; + (*list).length -= 1; + return Min; +} + +//P19.2 +//设计一个高效算法,将顺序表的所有元素逆置,要求算法的空间复杂度为O⑴ +void reverse(List* list) { + if (!list->length) + return; + for (int i = 0; i < (*list).length / 2; i++) { + swap(&(list->data[i]), &(list->data[list->length - i - 1])); + } +} + +//P19.3 +//对长度为n的顺序表L, 编写一个时间复杂度为O(m)空间复杂度为O(1)的算法, +//该算法删除线性表中所有值为x的数据元素 +void DeleteX(List* list, int X) { + for (int i = 0; i < (*list).length; i++) { + if ((*list).data[i] == X) { + for (int j = i + 1; j < (*list).length; j++) { + (*list).data[j - 1] = (*list).data[j]; + } + (*list).length -= 1; + break; + } + } +} + +//P19.4 +//从有序顺序表中删除其值在给定值s与t之间(要求s < t)的所有元素, 如果s或t不合 +//理或顺序表为空, 则显示出错信息并退出运行 +void OrderlyDelete(List* list, int X, int T) { + int i = 0, j = 0; + for (i; i < (*list).length; i++) + if ((*list).data[i] >= X) + break; + + for (j; j < (*list).length; j++) { + if ((*list).data[j] > T) + break; + } + int len = j - 1; + for (i; i < (*list).length; i++, j++) { + list->data[i] = list->data[j]; + } + list->length -= len; +} + +//P19.5 +//从顺序表中删除其值在给定值s与t之间(包含s和t, 要求s < t)的所有元素, +//如果s或t不合理或顺序表为空, 则显示出错信息并退出运行 +void DeleteS_T(List* list, int S, int T) { + if (S >= T || !list->length) + return; + + for (int i = 0; i < (*list).length; i++) { + if ((*list).data[i] >= S && (*list).data[i] <= T) { + for (int j = i + 1; j < (*list).length; j++) { + (*list).data[j - 1] = (*list).data[j]; + } + //要重新回退一个位置,重新检测,否则会跳过某些数字 + if (i) + i -= 1; + (*list).length -= 1; + } + } +} + +//P19.6 +//从有序顺序表中删除所有其值重复的元素,使表中所有元素的值均不同 + +void OlderlyDeleteSame(List* list) { + for (int i = 0; i < list->length; i++) { + if (list->data[i + 1] == list->data[i]) { + for (int j = i + 1; j < list->length; j++) { + list->data[j] = list->data[j + 1]; + } + list->length -= 1; + if (i) + i -= 1; + } + } +} + +//P19.7 +//将两个有序顺序表合并为一个新的有序顺序表, 并由函数返回结果顺序表 + +List MergeList(List A, List B) { + int i = 0, j = 0; + List C; + int k = 0; + while (i < A.length && j < B.length) { + if (A.data[i] >= B.data[j]) { + C.data[k++] = B.data[j++]; + } + else { + C.data[k++] = A.data[i++]; + } + } + while (i < A.length) { + C.data[k++] = A.data[i++]; + } + while (j < B.length) { + C.data[k++] = B.data[j++]; + } + C.length = k; + return C; +} + +//P19.8 +//已知在一维数组A[m + n]中依次存放两个线性表(a1, a2, a3…, am)和(b, b2, b3, …, bn)。试编 +//写一个函数, 将数组中两个顺序表的位置互换, 即将(b1,b2,b3,…, bn)放在(a1,a2, a3, …, am)的前面 + +void swaplist(List* A, int m, int n, int size) { + Reserve(A, 0, m + n - 1, size); + Reserve(A, 0, n - 1, size); + Reserve(A, n, m + n - 1, size); +} + +//P20.9线性表(a1,a2,a3,..,an)中的元素递增有序且按顺序存储于计算机内。 +//要求设计一算法, 完成用最少时间在表中查找数值为x的元素, 若找到则将其与后继元素位置相交换, +//若找不到则将其插入表中并使表中元素仍递增有序 + +//我的方法 大力出奇迹 +void CheckAndSwap(List* A, int x) { + bool flag = true; + _for(i, 0, A->length) { + if (A->data[i] == x) { + swap(&A->data[i], &A->data[i + 1]); + printf("Find it\n"); + flag = false; + break; + } + } + if (flag) { + printf("Not find\n"); + int i = 0; + for (i = 0; i < A->length && A->data[i] <= x; i++); + if (i < A->length) + { + for (int j = A->length; j >= i; j--) { + A->data[j + 1] = A->data[j]; + } + } + A->data[i] = x; + A->length += 1; + } +} + +//答案方法 折半查找 +void SearchExchangeInsert(List* A, int x) { + int low = 0, mid = A->length / 2, high = A->length - 1; + bool Isfind = false; + while (low <= high) { + mid = (low + high) / 2; + if (x == A->data[mid]) { + Isfind = true; + printf("Find\n"); + break; + } + if (x > A->data[mid]) { + low = mid + 1; + } + if (x < A->data[mid]) { + high = mid - 1; + } + } + if (Isfind && mid != A->length - 1) { + printf("Swap\n"); + swap(&A->data[mid], &A->data[mid + 1]); + } + if (!Isfind) { + int i = 0; + printf("%d", low); + for (i = A->length - 1; i > high; i--) { + A->data[i + 1] = A->data[i]; + } + A->data[i + 1] = x; + A->length += 1; + } +} + +//P20.10 +//〖2010统考真题〗设将n(n > 1)个整数存放到一维数组R中。设计一个在时间和空间两 +//方面都尽可能高效的算法。将R中保存的序列循环左移p(0length - 1, MAX); + Reserve(list, 0, list->length - 1, MAX); +} + +//P20.11 +//〖2011统考真题】一个长度为L(L≥1)的升序序列S, 处在第[L/2]个位置的数称为S的 +//中位数。例如, 若序列S1 = (1, 13, 15, 17, 19), 则S1的中位数是15, 两个序列的中位数 +//是含它们所有元素的升序序列的中位数。例如, 若S2 = (2, 4, 6, 8, 20), 则S1和S2的中位 +//数是11。现在有两个等长升序序列A和B, 试设计一个在时间和空间两方面都尽可能 +//高效的算法, 找出两个序列A和B的中位数。要求 +//1)给出算法的基本设计思想 +//2)根据设计思想, 采用C或C++或Java语言描述算法, 关键之处给出注释 +//3)说明你所设计算法的时间复杂度和空间复杂度 + +//改编的归并排序 +int FindMid(List A, List B) { + int i = 0, j = 0; + while (i + j != (A.length + B.length) / 2 - 1) { + if (A.data[i] <= B.data[j]) { + i++; + } + else { + j++; + } + } + return A.data[i] < B.data[j] ? A.data[i] : B.data[j]; +} + +//P20.12 +//〖2013统考真题〗已知一个整数序列A = (a0, a1…, an-1), 其中0 ≤ ai < n(0 ≤i < n)。若 +// 存在 ap1 = ap2 = ... = apm = x 且 m > n / 2 (0≤ Pk < n,1≤ k ≤ m), 则称x为A的主元素。 +// 例如A=(0,5,5,3,5,7,5,5),则5为主元素; 又如A = (0, 5, 5, 3, 5, 1, 5, 7), 则A中没有主 +// 元素。假设A中的n个元素保存在一个一维数组中, 请设计一个尽可能高效的算法, 找 +// 出A的主元素。若存在主元素, 则输岀该元素; 否则输出 - 1。要求: +//1)给出算法的基本设计思想 +//2)根据设计思想, 采用C或C十或Java语言描述算法, 关键之处给出注释 +//3)说明你所设计算法的时间复杂度和空间复杂度 + +//次优算法,用空间换时间,类似桶排 +int FindMain(List A, int n) { + int m_num = 0; + int* Box = new int[n](); //动态申请一个大小为n的数组 + _for(i, 0, A.length) { + Box[A.data[i]]++; + } + _for(i, 0, n) { + if (Box[i] > n / 2) { + return A.data[i]; + } + } + return -1; +} + +//P21.13 +//〖2018统考真题】给定一个含n(n≥1)个整数的数组, 请设计一个在时间上尽可能高效 +//的算法, 找出数组中未出现的最小正整数。例如, 数组{ -5,3,2,3 }中未出现的最小正整数 +//是1; 数组{ 1,2,3 }中未出现的最小正整数是4。要求 +//1)给出算法的基本设计思想 +//2)根据设计思想, 采用C或C艹语言描述算法, 关键之处给出注释 +//3)说明你所设计算法的时间复杂度和空间复杂度 + +//用空间换时间 +int FindMinNum(List A, int n) { + int* Box = new int[n + 1](); + _for(i, 0, A.length) { + if (A.data[i] > 0 && A.data[i] <= n) + Box[A.data[i]]++; + } + _for(i, 1, n) { + if (!Box[i]) + return i; + } + return -1; +} + +int main() +{ + List list1; + List list2; + list1.length = 4; + list2.length = 5; + int Data1[] = { 1,3,2,3 }; + int Data2[] = { 22,43,64,87,180 }; + + for (int i = 0; i < list1.length; i++) + list1.data[i] = Data1[i]; + + for (int i = 0; i < list2.length; i++) + list2.data[i] = Data2[i]; + + printf("%d", FindMinNum(list1, 4)); +} \ No newline at end of file