Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
30 changes: 30 additions & 0 deletions DataStructure/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -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"
}
]
}
17 changes: 17 additions & 0 deletions DataStructure/.vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -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"
}
]
}
29 changes: 29 additions & 0 deletions DataStructure/ProDataStructre/Headers/LinearList.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#ifndef H_LINEARLIST_H
#define H_LINEARLIST_H

#define true 1
#define flase 0

template <class T>
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
68 changes: 68 additions & 0 deletions DataStructure/ProDataStructre/Headers/seqList.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
#ifndef _SEQLIST_H
#define _SEQLIST_H

#include <iostream>
#include "LinearList.h"

using namespace std;

const int defaultSize = 100;
template <class T>
class SeqList : public LinearList<T>
{
protected:
T *data;
int maxSize;
int last;
void reSize(int newSize);

public:
SeqList(int sz = defaultSize); //构造函数
SeqList(SeqList<T> &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 <class T>
SeqList<T>::SeqList(int sz)
{
//通过指定sz的值来确定表的容量
if (sz > 0) //sz合法
{
maxSize = sz; last = -1;
data = new T[maxSize];
if (data == NULL)
{
cerr << "存储分配有错误!" << endl;
exit(1);
}
}
}


#endif
Binary file added DataStructure/ProDataStructre/Sources/main
Binary file not shown.
9 changes: 9 additions & 0 deletions DataStructure/ProDataStructre/Sources/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#include <iostream>

using namespace std;

int main()
{
cout << "Hello VsCode!" << endl;
return 0;
}
17 changes: 17 additions & 0 deletions DataStructure/makefile
Original file line number Diff line number Diff line change
@@ -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)
66 changes: 66 additions & 0 deletions DataStructure/newPro.sh
Original file line number Diff line number Diff line change
@@ -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 <iostream> " >> $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
Binary file added DataStructure/out
Binary file not shown.
76 changes: 76 additions & 0 deletions new
Original file line number Diff line number Diff line change
@@ -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 <iostream> \" >> \\$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"
}
}
7 changes: 6 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
hello!
这个工程记录了本人学习《数据结构》的全过程。
一、线性表
1、顺序表
2、链表
(1)、一般链表
(2)、循环链表