資源簡介
用無向網表示校園景點平面圖,圖中頂點表示主要景點,存放景點的編號、名稱、簡介等信息,圖中的邊表示景點間的道路,存放路徑長度等信息。要求能夠回答有關景點介紹、游覽路徑等問題。成績95
基本要求:
①查詢任意景點的相關信息;
②查詢圖中任意兩個景點間的最短路徑。
③查詢圖中任意兩個景點間的所有路徑。
④增加、刪除、更新有關景點和道路的信息。
(選作) *求多個景點的最佳(最短)游覽路徑。

代碼片段和文件信息
#include?
#include?
using?namespace?std;
typedef?struct?Node?{
????int?data;
????struct?Node?*next?=?nullptr;
}Node*linklist;
int?**kk?=?new?int*[10];
int?num?=?0;
int?time?=?0;
void?bfssort(Node?*w)?{
????while?(w->next?!=?nullptr)?{
????????w?=?w->next;
????????time++;
????????if?(time?!=?1)
????????????cout?<““;
????????cout?<data;
????????int?ps?=?1;
????????while?(ps?????????????ps++;
????????????if?(ps?==?w->data)
????????????????continue;
????????????if?(kk[w->data][ps]?!=?0?&&?kk[ps][ps]?==?0)?{
????????????????kk[ps][ps]?=?1;
????????????????Node?*q?=?new?Node?;
????????????????q?=?w;
????????????????while?(q->next?!=?nullptr)
????????????????????q?=?q->next;
????????????????Node?*r?=?new?Node;
????????????????r->data?=?ps;
????????????????q->next?=?r;
????????????}
????????}
????}
}
void?dfssort(int?bb)?{
????time++;
????if?(time?!=?1)
????????cout?<““;
????cout?<????int?col?=?1;
????while?(col?????????col++;
????????if?(col?==?bb)
????????????continue;
????????if?(kk[bb][col]?!=?0)?{
????????????if?(kk[col][col]?!=?0?&&?kk[col][col]?>kk[bb][bb]?+?kk[bb][col])?{
????????????????kk[col][col]?=kk[bb][bb]?+kk[bb][col];
????????????????int?t?=?1;
????????????????while?(t?????????????????????t++;
????????????????????if?(kk[t][t]?>?kk[t][col]?+?kk[col][col])
????????????????????????kk[t][t]?=?kk[t][col]?+?kk[col][col];
????????????????}
????????????}????????????if?(kk[col][col]?==?0)?{
????????????????kk[col][col]?=?kk[bb][bb]?+?kk[bb][col];
????????????????dfssort(col);
????????????}
????????}
????}
}
int?main()?{
????int?t2?=?0;
????while?(t2?10)?{
????????kk[t2]?=?new?int[10];
????????int?tt?=?0;
????????while?(tt?10)?{
????????????kk[t2][tt]?=?0;
????????????tt++;
????????}
????????t2++;
????}
????cout?<“Input“?<????string?sr;
????cin?>>?sr;
????int?l?=?sr.length();
????num?=?sr[0]?-?48;
????int?m?=?0;
????t2?=?2;
????while?(t2?????????m?*=?10;
????????m?+=?sr[t2]?-?48;
????????t2++;
????}
????t2?=?0;
????while?(t2?????????cin?>>?sr;
????????l?=?sr.length();
????????int?a?=?sr[0]?-?48;
????????int?b?=?sr[2]?-?48;
????????int?c?=?0;
????????int?tt1?=?4;
????????while?(tt1????????????c?*=?10;
????????????c?+=?sr[tt1]?-?48;
????????????tt1++;
????????}
????????kk[a][b]?=?c;
????????kk[b][a]?=?c;
????????t2++;
????}
????cout?<“Output“?<????Node?*p?=?new?Node;
????Node?*q?=?new?Node;
????q->data?=?1;
????p->next?=?q;
????kk[1][1]?=?0;
????bfssort(p);
????cout?<????t2?=?2;
????while?(t2?10)?{
????????kk[t2][t2]?=0;
????????t2++;
????}
????time?=?0;
????dfssort(1);
????cout?<????cout?<????cout?<“End“;
????return?0;
}
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2020-05-11?20:35??test\
?????目錄???????????0??2020-05-11?20:35??test\.idea\
?????文件?????????295??2019-12-13?09:32??test\.idea\encodings.xm
?????文件?????????246??2019-11-26?11:39??test\.idea\misc.xm
?????文件?????????267??2019-11-26?11:38??test\.idea\modules.xm
?????文件??????????98??2019-11-26?11:39??test\.idea\test.iml
?????文件????????5802??2020-01-18?09:26??test\.idea\workspace.xm
?????文件?????????109??2019-11-26?11:38??test\CMakeLists.txt
?????目錄???????????0??2020-05-11?20:35??test\cmake-build-debug\
?????文件???????47536??2019-12-01?22:06??test\cmake-build-debug\CMakeCache.txt
?????目錄???????????0??2020-05-11?20:35??test\cmake-build-debug\CMakeFiles\
?????目錄???????????0??2020-05-11?20:35??test\cmake-build-debug\CMakeFiles\3.14.5\
?????文件????????2524??2019-11-26?11:38??test\cmake-build-debug\CMakeFiles\3.14.5\CMakeCCompiler.cmake
?????文件????????5372??2019-11-26?11:38??test\cmake-build-debug\CMakeFiles\3.14.5\CMakeCXXCompiler.cmake
?????文件???????42127??2019-11-26?11:38??test\cmake-build-debug\CMakeFiles\3.14.5\CMakeDetermineCompilerABI_C.bin
?????文件???????43156??2019-11-26?11:38??test\cmake-build-debug\CMakeFiles\3.14.5\CMakeDetermineCompilerABI_CXX.bin
?????文件?????????234??2019-11-26?11:38??test\cmake-build-debug\CMakeFiles\3.14.5\CMakeRCCompiler.cmake
?????文件?????????395??2019-11-26?11:38??test\cmake-build-debug\CMakeFiles\3.14.5\CMakeSystem.cmake
?????目錄???????????0??2020-05-11?20:35??test\cmake-build-debug\CMakeFiles\3.14.5\CompilerIdC\
?????文件???????20714??2019-11-26?11:38??test\cmake-build-debug\CMakeFiles\3.14.5\CompilerIdC\CMakeCCompilerId.c
?????文件???????42759??2019-11-26?11:38??test\cmake-build-debug\CMakeFiles\3.14.5\CompilerIdC\a.exe
?????目錄???????????0??2020-05-28?08:18??test\cmake-build-debug\CMakeFiles\3.14.5\CompilerIdC\tmp\
?????目錄???????????0??2020-05-11?20:35??test\cmake-build-debug\CMakeFiles\3.14.5\CompilerIdCXX\
?????文件???????20229??2019-11-26?11:38??test\cmake-build-debug\CMakeFiles\3.14.5\CompilerIdCXX\CMakeCXXCompilerId.cpp
?????文件???????43807??2019-11-26?11:38??test\cmake-build-debug\CMakeFiles\3.14.5\CompilerIdCXX\a.exe
?????目錄???????????0??2020-05-28?08:18??test\cmake-build-debug\CMakeFiles\3.14.5\CompilerIdCXX\tmp\
?????目錄???????????0??2020-05-11?20:35??test\cmake-build-debug\CMakeFiles\3.15.3\
?????文件????????2567??2019-12-01?22:06??test\cmake-build-debug\CMakeFiles\3.15.3\CMakeCCompiler.cmake
?????文件????????5417??2019-12-01?22:06??test\cmake-build-debug\CMakeFiles\3.15.3\CMakeCXXCompiler.cmake
?????文件???????42127??2019-12-01?22:06??test\cmake-build-debug\CMakeFiles\3.15.3\CMakeDetermineCompilerABI_C.bin
?????文件???????43156??2019-12-01?22:06??test\cmake-build-debug\CMakeFiles\3.15.3\CMakeDetermineCompilerABI_CXX.bin
............此處省略42個文件信息
- 上一篇:微信小程序聊天(仿微信).zip
- 下一篇:2019天勤數據結構視頻.txt
評論
共有 條評論