diff --git a/DataStructure/.vscode/ipch/30e0eca0c8aed4b4/mmap_address.bin b/DataStructure/.vscode/ipch/30e0eca0c8aed4b4/mmap_address.bin new file mode 100644 index 0000000..c85e670 Binary files /dev/null and b/DataStructure/.vscode/ipch/30e0eca0c8aed4b4/mmap_address.bin differ diff --git a/DataStructure/.vscode/ipch/30e0eca0c8aed4b4/seqList.ipch b/DataStructure/.vscode/ipch/30e0eca0c8aed4b4/seqList.ipch new file mode 100644 index 0000000..0f497d1 Binary files /dev/null and b/DataStructure/.vscode/ipch/30e0eca0c8aed4b4/seqList.ipch differ diff --git a/DataStructure/.vscode/ipch/99e2334f22b92a31/main.ipch b/DataStructure/.vscode/ipch/99e2334f22b92a31/main.ipch new file mode 100644 index 0000000..f6d06c1 Binary files /dev/null and b/DataStructure/.vscode/ipch/99e2334f22b92a31/main.ipch differ diff --git a/DataStructure/.vscode/ipch/99e2334f22b92a31/mmap_address.bin b/DataStructure/.vscode/ipch/99e2334f22b92a31/mmap_address.bin new file mode 100644 index 0000000..3681baa Binary files /dev/null and b/DataStructure/.vscode/ipch/99e2334f22b92a31/mmap_address.bin differ diff --git a/DataStructure/.vscode/ipch/b1a1881909af0198/mmap_address.bin b/DataStructure/.vscode/ipch/b1a1881909af0198/mmap_address.bin new file mode 100644 index 0000000..9b840d4 Binary files /dev/null and b/DataStructure/.vscode/ipch/b1a1881909af0198/mmap_address.bin differ diff --git a/DataStructure/.vscode/launch.json b/DataStructure/.vscode/launch.json new file mode 100644 index 0000000..7b37d49 --- /dev/null +++ b/DataStructure/.vscode/launch.json @@ -0,0 +1,30 @@ +{ + // 使用 IntelliSense 了解相关属性。 + // 悬停以查看现有属性的描述。 + // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "g++ build and debug active file", + "type": "cppdbg", + "request": "launch", + "program": "${workspaceFolder}/out", + "args": [], + "stopAtEntry": false, + "cwd": "${workspaceFolder}", + "environment": [], + "externalConsole": true, + "MIMode": "gdb", + "setupCommands": [ + { + "description": "Enable pretty-printing for gdb", + "text": "-enable-pretty-printing", + "ignoreFailures": true + } + ], + "preLaunchTask": "build", + "postDebugTask": "clean", + "miDebuggerPath": "/usr/bin/gdb" + } + ] +} \ No newline at end of file diff --git a/DataStructure/.vscode/tasks.json b/DataStructure/.vscode/tasks.json new file mode 100644 index 0000000..6725b9c --- /dev/null +++ b/DataStructure/.vscode/tasks.json @@ -0,0 +1,17 @@ +{ + // See https://go.microsoft.com/fwlink/?LinkId=733558 + // for the documentation about the tasks.json format + "version": "2.0.0", + "tasks": [ + { + "label": "build", + "type": "shell", + "command": "make" + }, + { + "label": "clean", + "type": "shell", + "command": "make clean" + } + ] +} \ No newline at end of file diff --git a/DataStructure/ProDataStructre/Headers/LinearList.h b/DataStructure/ProDataStructre/Headers/LinearList.h new file mode 100644 index 0000000..c85055f --- /dev/null +++ b/DataStructure/ProDataStructre/Headers/LinearList.h @@ -0,0 +1,29 @@ +#ifndef H_LINEARLIST_H +#define H_LINEARLIST_H + +#define true 1 +#define flase 0 + +template +class LinearList +{ +public: + LinearList(); + ~LinearList(); + virtual int Size() const = 0; + virtual int Length() const = 0; + virtual int Search(T &x) const = 0; + virtual int Locate(int i) const = 0; + virtual bool getData(int i, T &x) const = 0; + virtual void setData(int i, T &x) = 0; + virtual bool Insert(int i, T &x) = 0; + virtual bool Remove(int i, T &x) = 0; + virtual bool IsEmpty() const = 0; + virtual bool IsFull() const = 0; + virtual void Sort() = 0; + virtual void input() = 0; + virtual void output() = 0; +}; + + +#endif \ No newline at end of file diff --git a/DataStructure/ProDataStructre/Headers/seqList.h b/DataStructure/ProDataStructre/Headers/seqList.h new file mode 100644 index 0000000..61d3f0a --- /dev/null +++ b/DataStructure/ProDataStructre/Headers/seqList.h @@ -0,0 +1,68 @@ +#ifndef _SEQLIST_H +#define _SEQLIST_H + +#include +#include "LinearList.h" + +using namespace std; + +const int defaultSize = 100; +template +class SeqList : public LinearList +{ +protected: + T *data; + int maxSize; + int last; + void reSize(int newSize); + +public: + SeqList(int sz = defaultSize); //构造函数 + SeqList(SeqList &L); //构造函数 + ~SeqList() { delete[] data; } //析构函数 + int Size() const { return maxSize; } //返回最大容量 + int Length() const { return last + 1; } //返回当前长度 + int Search(T &x) const; //搜索x在表中的位置 + int Locate(int i) const; //定位第i个表项 + bool getData(int i, T &x) const //获得第i项的值 + { + if (i > 0 && i <= last + 1) + { + x = data[i - 1]; + return true; + } + else + return false; + } + void setData(int i, T &x) //设置第i项的值 + { + if (i > 0 && i <= last + 1) + data[i - 1] = x; + } + bool Insert(int i, T &x); //将x插入到第i项中 + bool Remove(int i, T &x); //删除第i项 + bool IsEmpty() { return (last == -1) ? true : false; } //判断是否为空 + bool IsFull() { return (last == maxSize) ? true : false; } //判断是否满表 + void intput(); //输入表 + void output(); //输出表 +}; + +//构造函数 +template +SeqList::SeqList(int sz) +{ + //通过指定sz的值来确定表的容量 + if (sz > 0) //sz合法 + { + maxSize = sz; last = -1; + data = new T[maxSize]; + if (data == NULL) + { + cerr << "存储分配有错误!" << endl; + exit(1); + } + } +} + + +#endif \ No newline at end of file diff --git a/DataStructure/ProDataStructre/Sources/main b/DataStructure/ProDataStructre/Sources/main new file mode 100755 index 0000000..b23052c Binary files /dev/null and b/DataStructure/ProDataStructre/Sources/main differ diff --git a/DataStructure/ProDataStructre/Sources/main.cpp b/DataStructure/ProDataStructre/Sources/main.cpp new file mode 100644 index 0000000..4834a09 --- /dev/null +++ b/DataStructure/ProDataStructre/Sources/main.cpp @@ -0,0 +1,9 @@ +#include + +using namespace std; + +int main() +{ + cout << "Hello VsCode!" << endl; + return 0; +} diff --git a/DataStructure/makefile b/DataStructure/makefile new file mode 100644 index 0000000..55f1f7f --- /dev/null +++ b/DataStructure/makefile @@ -0,0 +1,17 @@ +# 头文件存放目录 +header := ./ProDataStructre/Headers/ +# 源文件存放目录 +source := ./ProDataStructre/Sources/ + +executable := out +sources := $(wildcard $(source)*.cpp) +objects := $(sources:.cpp=.o) + +$(executable) : $(objects) + g++ -o $@ $^ +$(objects) : %.o:%.cpp + g++ -o $@ -c -g $< -I $(header) + +.PHONY : clean +clean : + -rm $(objects) diff --git a/DataStructure/newPro.sh b/DataStructure/newPro.sh new file mode 100755 index 0000000..cd3e27f --- /dev/null +++ b/DataStructure/newPro.sh @@ -0,0 +1,66 @@ +# 输入一个文件名 + +echo "请输入项目名:" +read projectname + +# 添加前缀 +filename="Pro"$projectname + +#选择 +echo -e "请选择:\n1、建立项目\n2、删除项目" +read choice + +if [ $choice == 1 ] +then + + # 源文件目录 + Src="$filename/Sources" + + # 头文件目录 + Inc="$filename/Headers" + + # 创建项目树 + mkdir -p $Src $Inc + + # 创建makefile文件 + touch makefile + + # 创建 main.cpp文件 + touch $Src/main.cpp + + # 向main.cpp中写入内容 + echo "#include " >> $Src/main.cpp + echo "" >> $Src/main.cpp + echo "using namespace std;" >> $Src/main.cpp + echo "" >> $Src/main.cpp + echo "int main()" >> $Src/main.cpp + echo "{" >> $Src/main.cpp + echo " cout << \"Hello VsCode!\" << endl;" >> $Src/main.cpp + echo " return 0;" >> $Src/main.cpp + echo "}" >> $Src/main.cpp + + # 导入makefile + echo "# 头文件存放目录" >> makefile + echo "header := ./$Inc/" >> makefile + echo "# 源文件存放目录" >> makefile + echo "source := ./$Src/" >> makefile + + echo "" >> makefile + echo "executable := out" >> makefile + echo "sources := \$(wildcard \$(source)*.cpp)" >> makefile + echo "objects := \$(sources:.cpp=.o)" >> makefile + + echo "" >> makefile + echo "\$(executable) : \$(objects)" >> makefile + echo -e "\tg++ -o \$@ \$^" >> makefile + echo "\$(objects) : %.o:%.cpp" >> makefile + echo -e "\tg++ -o \$@ -c -g \$< -I \$(header)" >> makefile + echo "" >> makefile + echo ".PHONY : clean" >> makefile + echo "clean :" >> makefile + echo -e "\t-rm \$(objects)" >> makefile +else + rm -rf $filename + rm -rf makefile + rm -rf out +fi \ No newline at end of file diff --git a/DataStructure/out b/DataStructure/out new file mode 100755 index 0000000..f26150b Binary files /dev/null and b/DataStructure/out differ diff --git a/new b/new new file mode 100644 index 0000000..6fed363 --- /dev/null +++ b/new @@ -0,0 +1,76 @@ +{ + "Makefile": { + "prefix": "new.sh", + "body": [ + "# 输入一个文件名 $projectname", + "echo \"请输入项目名:\"", + "read projectname", + "", + "# 添加前缀", + "filename=\"Pro\"\\$projectname", + "", + "#选择", + "echo -e \"请选择:\\n1、建立项目\\n2、删除项目\"", + "read choice", + "", + "if [ \\$choice == 1 ]", + "then", + "", + "\t# 源文件目录", + "\tSrc=\"\\$filename/Sources\"", + "", + "\t# 头文件目录", + "\tInc=\"\\$filename/Headers\"", + "", + "\t# 创建项目树", + "\tmkdir -p \\$Src \\$Inc", + "", + "\t# 创建makefile文件", + "\ttouch makefile", + "", + "\t# 创建 main.cpp文件", + "\ttouch \\$Src/main.cpp", + "", + "\t# 向main.cpp中写入内容", + "\techo \"#include \" >> \\$Src/main.cpp", + "\techo \"\" >> \\$Src/main.cpp", + "\techo \"using namespace std;\" >> \\$Src/main.cpp", + "\techo \"\" >> \\$Src/main.cpp", + "\techo \"int main()\" >> \\$Src/main.cpp", + "\techo \"{\" >> \\$Src/main.cpp", + "\techo \" cout << \\\"Hello VsCode!\\\" << endl;\" >> \\$Src/main.cpp", + "\techo \" return 0;\" >> \\$Src/main.cpp", + "\techo \"}\" >> \\$Src/main.cpp", + "", + "\t# 导入makefile", + "\techo \"# 头文件存放目录\" >> makefile", + "\techo \"header := ./\\$Inc/\" >> makefile", + "\techo \"# 源文件存放目录\" >> makefile", + "\techo \"source := ./\\$Src/\" >> makefile", + "", + "\techo \"\" >> makefile", + "\techo \"executable := out\" >> makefile", + "\techo \"sources := \\\\$(wildcard \\\\$(source)*.cpp)\" >> makefile", + "\techo \"objects := \\\\$(sources:.cpp=.o)\" >> makefile", + "", + "\techo \"\" >> makefile", + "\techo \"\\\\$(executable) : \\\\$(objects)\" >> makefile", + "\techo -e \"\\tg++ -o \\\\$@ \\\\$^\" >> makefile", + "\techo \"\\\\$(objects) : %.o:%.cpp\" >> makefile", + "\techo -e \"\\tg++ -o \\\\$@ -c -g \\\\$< -I \\\\$(header)\" >> makefile", + "\techo \"\" >> makefile", + "\techo \".PHONY : clean\" >> makefile", + "\techo \"clean :\" >> makefile", + "\techo -e \"\\t-rm \\\\$(objects)\" >> makefile", + + + "else", + "\trm -rf \\$filename", + "\trm -rf makefile", + "\trm -rf out", + "fi" + + ], + "description": "Log output to console" + } +} diff --git a/readme.txt b/readme.txt index 3462721..d7461de 100644 --- a/readme.txt +++ b/readme.txt @@ -1 +1,6 @@ -hello! \ No newline at end of file +这个工程记录了本人学习《数据结构》的全过程。 +一、线性表 + 1、顺序表 + 2、链表 + (1)、一般链表 + (2)、循环链表