diff --git a/ex11/ex11.cpp b/ex11/ex11.cpp index 71e57d6..9ae0181 100644 --- a/ex11/ex11.cpp +++ b/ex11/ex11.cpp @@ -1,8 +1,41 @@ #include "graph.hpp" +#include #include + int main() { - graphVertex gv; - printf("OK"); + graphVertex gv; + int op, id1, id2, w; + std::string name; + while (1) + { + printf("选择操作:1添加节点2添加边3删除节点4删除边\n"); + scanf("%d", &op); + switch (op) + { + case 1: + printf("分别输入序号 节点名:"); + std::cin >> id1 >> name; + gv.insect(id1, name); + break; + case 2: + printf("分别输入起始节点序号 到达节点序号 边权重:"); + std::cin >> id1 >> id2 >> w; + gv.link(id1, id2, w); + break; + case 3: + printf("输入节点序号:"); + std::cin >> id1; + break; + case 4: + printf("分别输入起始节点序号 到达节点序号:"); + std::cin >> id1 >> id2; + gv.unlink(id1, id2); + break; + default: + break; + } + } + return 0; } \ No newline at end of file diff --git a/ex11/graph.hpp b/ex11/graph.hpp index c3c1803..8577c00 100644 --- a/ex11/graph.hpp +++ b/ex11/graph.hpp @@ -136,7 +136,7 @@ public: // -1 顶点不存在 // -2 边不存在 // 0 成功 - virtual int unlink(int id1, int id2, int w) + virtual int unlink(int id1, int id2) { if (V[id1] == NULL || V[id2] == NULL) return -1; diff --git a/workspace.code-workspace b/workspace.code-workspace index 45474dc..8707dda 100644 --- a/workspace.code-workspace +++ b/workspace.code-workspace @@ -14,7 +14,37 @@ "stdexcept": "cpp", "streambuf": "cpp", "istream": "cpp", - "array": "cpp" + "array": "cpp", + "atomic": "cpp", + "cctype": "cpp", + "clocale": "cpp", + "cmath": "cpp", + "cstdarg": "cpp", + "cstddef": "cpp", + "cstdint": "cpp", + "cstdio": "cpp", + "cstdlib": "cpp", + "cwchar": "cpp", + "cwctype": "cpp", + "deque": "cpp", + "unordered_map": "cpp", + "vector": "cpp", + "exception": "cpp", + "algorithm": "cpp", + "memory": "cpp", + "memory_resource": "cpp", + "optional": "cpp", + "system_error": "cpp", + "tuple": "cpp", + "type_traits": "cpp", + "utility": "cpp", + "fstream": "cpp", + "initializer_list": "cpp", + "iosfwd": "cpp", + "limits": "cpp", + "new": "cpp", + "ostream": "cpp", + "typeinfo": "cpp" } } } \ No newline at end of file