From e00a3e7febaf2aec7c2e802d80fb6100e95de32d Mon Sep 17 00:00:00 2001 From: xusun000 <2235861811@qq.com> Date: Mon, 27 Feb 2023 18:31:21 +0800 Subject: [PATCH] =?UTF-8?q?update=EF=BC=9A=E6=8F=90=E4=BA=A42023=E5=B9=B44?= =?UTF-8?q?08=E6=95=B0=E6=8D=AE=E7=BB=93=E6=9E=84=E7=AE=97=E6=B3=95?= =?UTF-8?q?=E9=A2=98=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 3 +- .idea/.gitignore | 8 ----- .vscode/c_cpp_properties.json | 14 -------- .vscode/launch.json | 41 ++++++++++------------ .vscode/settings.json | 2 ++ .vscode/tasks.json | 66 ++++++++++++++--------------------- 2023_get_kVertice.cpp | 51 +++++++++++++++++++++++++++ 7 files changed, 100 insertions(+), 85 deletions(-) delete mode 100644 .idea/.gitignore delete mode 100644 .vscode/c_cpp_properties.json create mode 100644 2023_get_kVertice.cpp diff --git a/.gitignore b/.gitignore index c2a693d..f87ece0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ cmake-build-debug CMakeLists.txt .idea -*.exe \ No newline at end of file +*.exe +.out \ No newline at end of file diff --git a/.idea/.gitignore b/.idea/.gitignore deleted file mode 100644 index 35410ca..0000000 --- a/.idea/.gitignore +++ /dev/null @@ -1,8 +0,0 @@ -# 默认忽略的文件 -/shelf/ -/workspace.xml -# 基于编辑器的 HTTP 客户端请求 -/httpRequests/ -# Datasource local storage ignored files -/dataSources/ -/dataSources.local.xml diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json deleted file mode 100644 index 1868be1..0000000 --- a/.vscode/c_cpp_properties.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "configurations": [ - { - "cStandard": "c18", - "compilerPath": "C:\\Program Files\\mingw64\\mingw64\\bin\\gcc.exe", - "includePath": [ - "${workspaceFolder}/**" - ], - "intelliSenseMode": "windows-gcc-x64", - "name": "Win32" - } - ], - "version": 4 -} \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json index 9e1c32d..3b46352 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -1,26 +1,21 @@ { - "configurations": [ - { - "MIMode": "gdb", - "args": [], - "cwd": "${fileDirname}", - "environment": [], - "externalConsole": false, - "internalConsoleOptions": "neverOpen", - "miDebuggerPath": "C:\\Program Files\\mingw64\\mingw64\\bin\\gdb.exe", - "name": "gcc single file debug", - "preLaunchTask": "gcc single file build", - "program": "${fileDirname}\\${fileBasenameNoExtension}.exe", - "request": "launch", - "setupCommands": [ + // 使用 IntelliSense 了解相关属性。 + // 悬停以查看现有属性的描述。 + // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ { - "ignoreFailures": true, - "text": "-enable-pretty-printing" + "name": "(lldb) 启动", + "preLaunchTask": "C/C++: clang++ 生成活动文件",//调试前执行的任务,就是之前配置的tasks.json中的label字段 + "type": "cppdbg", + "request": "launch", + "program": "${workspaceFolder}/.out/${fileBasenameNoExtension}.out", + "args": [], + "stopAtEntry": false, + "cwd": "${fileDirname}", + "environment": [], + "externalConsole": false, + "MIMode": "lldb" } - ], - "stopAtEntry": false, - "type": "cppdbg" - } - ], - "version": "0.2.0" -} \ No newline at end of file + ] +} diff --git a/.vscode/settings.json b/.vscode/settings.json index e69de29..7a73a41 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -0,0 +1,2 @@ +{ +} \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 8717562..f1d8052 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -1,41 +1,29 @@ { - "options": { - "env": { - "Path": "C:\\Program Files\\mingw64\\mingw64\\bin;${env:Path}" - }, - "shell": { - "args": [ - "/C" - ], - "executable": "C:\\Windows\\System32\\cmd.exe" - } - }, - "tasks": [ - { - "args": [ - "-std=c18", - "-g", - "${file}", - "-o", - "${fileDirname}\\${fileBasenameNoExtension}.exe" - ], - "command": "C:\\Program Files\\mingw64\\mingw64\\bin\\gcc.exe", - "group": { - "isDefault": true, - "kind": "build" - }, - "label": "gcc single file build", - "presentation": { - "clear": true, - "echo": false, - "focus": false, - "panel": "shared", - "reveal": "silent", - "showReuseMessage": false - }, - "problemMatcher": "$gcc", - "type": "process" - } - ], - "version": "2.0.0" + "tasks": [ + { + "type": "cppbuild", + "label": "C/C++: clang++ 生成活动文件", + "command": "/usr/bin/clang++", + "args": [ + "-fcolor-diagnostics", + "-fansi-escape-codes", + "-g", + "${file}", + "-o", + "${workspaceFolder}/.out/${fileBasenameNoExtension}.out" + ], + "options": { + "cwd": "${fileDirname}" + }, + "problemMatcher": [ + "$gcc" + ], + "group": { + "kind": "build", + "isDefault": true + }, + "detail": "调试器生成的任务。" + } + ], + "version": "2.0.0" } \ No newline at end of file diff --git a/2023_get_kVertice.cpp b/2023_get_kVertice.cpp new file mode 100644 index 0000000..42ed40e --- /dev/null +++ b/2023_get_kVertice.cpp @@ -0,0 +1,51 @@ +#include +#include +#include +#define MAXV 4 + +typedef struct { // 图的定义 + int numVertices, numEdges; // 图中实际的顶点数和边数 + char VerticesList[MAXV]; // 顶点表,MAXV为已定义常量 + int Edge[MAXV][MAXV]; // 邻接矩阵 +} MGraph; + +int printVertices(MGraph* G) { + int count = 0, indegree = 0, outdegree = 0; + // 遍历无向图统计所有点的出度和入度 + for (int i = 0; i < G->numVertices; i++) { + indegree = 0; // i的入度 + outdegree = 0; // i的出度 + for (int j = 0; j < G->numVertices; j++) { + outdegree += G->Edge[i][j]; + indegree += G->Edge[j][i]; + } + if (outdegree > indegree) { + printf("K顶点的个数为:%d\n", i); + count++; + } + } + return count; +} + +int main() { + MGraph* m = new MGraph(); + m->numVertices = 4; + m->numEdges = 5; + for (int i = 0; i < 4; i++) { + m->VerticesList[i] = 'a' + i; + } + /** + * m->Edge + * [0,1,0,1] + * [0,0,1,1] + * [0,0,0,1] + * [0,0,0,0] + */ + m->Edge[0][1] = 1; + m->Edge[0][3] = 1; + m->Edge[1][2] = 1; + m->Edge[1][3] = 1; + m->Edge[2][3] = 1; + printVertices(m); + return 0; +}