CutionAlert
Kona   Weihai, Shandong, China
 
 
:Karin: 一人では無理です.
Commencing Test Now.
Currently Offline
Screenshot Showcase
World_of_Warships
DiJIStra Algorithm
// 单源最短路径和DJkstra算法.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。
//

#include <iostream>
#include<string>
using namespace std;
const int N = 20;
const int INF = 32767;
typedef struct node
{
int adj;
int weight;
struct node* nextarc;
}arcNode;
typedef struct
{
string data;
arcNode* firstArc;

}vexNode;
typedef struct
{
int n, e;
vexNode adjlist[N];
}AdjGraph;

void createGraph(AdjGraph &g)
{
cin >> g.n >> g.e;
for (int i = 0; i < g.n; i++)
{
cin >> g.adjlist .data;
g.adjlist .firstArc = NULL;
}
int u, v, w;
for (int i = 0; i < g.e; i++)
{
cin >> u >> v >> w;
arcNode* s = new arcNode;//为弧分配空间
s->adj = v;
s->weight = w;

s->nextarc = g.adjlist .firstArc;
g.adjlist .firstArc = s;
}
}
int FindMinDist(int s[],int dist[], int n)
{
int k = -1;
int minV = INF + 1;
for (int i = 0; i < n; i++)
{
if(s ==0 && dist <minV)
{
minV = dist ;
k = i;
}
}
return k;
}
void outputPath(AdjGraph& g, int v, int u, int path[])
{
if (v == u) cout << g.adjlist[v].data;
else
{
outputPath(g, v, path , path);
cout << " -> " << g.adjlist .data;
}
}

void sortDjStra(AdjGraph &g,int v)
{
int s[N] = { 0 }; //元素集合
int path[N], dist[N];

for (int i = 0; i < g.n; i++)
{
path = -1; dist = INF;
}

s[v] = 1;

arcNode* p = g.adjlist[v].firstArc;
int u;
while (p)
{
u = p->adj;
dist = p->weight;
path = v;
p = p->nextarc;
}

for (int i = 0; i < g.n-1; i++)
{
int k = FindMinDist(s, dist, g.n);
if (dist[k] == INF) break;

s[k] = 1;
arcNode* p = g.adjlist[k].firstArc;
while (p)
{
u = p->adj;
if(dist[k]+p->weight <dist )
{
dist = dist[k] + p->weight;
path = k;
}
p = p->nextarc;
}
}
//输出最短路径长度
for (int i = 0; i < g.n; i++)
{
if (i != v)
{
if (dist != INF)
{
outputPath(g, v, i, path);
cout << " :" << dist << endl;
}
}
else cout << g.adjlist[v].data << " -> " << g.adjlist .data << " :No Path"<<endl; }}int main(){ AdjGraph g; createGraph(g); sortDjStra(g, 0); return 0;}//test data/*7 12v0 v1 v2 v3 v4 v5 v60 1 40 2 60 3 61 2 11 4 72 4 62 5 43 2 23 5 54 6 65 4 15 6 8*/
Favorite Game
Favorite Group
bilibili - Public Group
Welcome to Official Steam Group for bilibili!
95,435
Members
3,404
In-Game
12,522
Online
24,641
In Chat
Workshop Showcase
12 ratings
Created by - CutionAlert
Review Showcase
Some time people acturally need you ,but they just don't want to admit it.
(有些时候人们需要你,只是他们不愿意承认)
Favorite Guide
Created by - Senloo
1,014 ratings
本指南为ICEY(艾希)的全成就指南,由于游戏可以选取存档点进行继续游戏,建议先由自己探索完之后,再通过本指南来获得剩下未获得的成就。希望能对您有所帮助
Items Up For Trade
727
Items Owned
8
Trades Made
683
Market Transactions
Recent Activity
3,748 hrs on record
last played on 16 Dec
18.9 hrs on record
last played on 13 Dec
14.7 hrs on record
last played on 13 Dec
祝新年快乐!望在新的一年里,龙行龘龘,前程朤朤!(Happy Chinese New Year!)
苍山洱海 4 May, 2022 @ 2:09am 
五一劳动节快乐!
常盤台のレールガン 1 Jan, 2022 @ 7:52pm 
“苦难有如乌云,远望去但见墨黑一片,然而身临其下时不过是灰色而已。”
幸运并非没有恐惧和烦恼;厄运也决非没有安慰和希望,也许当我们回望过去的时候,2021不会是最美好的那一个,但也绝不会是最平凡的那一个,一切都因灾祸痛苦而遗憾,一切也都因挺身而出的人闪耀而慰藉,在这片灰蒙蒙的景观之下,希望我们能依旧以满腔热血奔向这个充满希冀的2022,也祝你在即将到来的日子里永葆青春、充满活力!
常盤台のレールガン 11 Feb, 2021 @ 8:12am 
新春快乐!
常盤台のレールガン 11 Feb, 2021 @ 6:50am 
lona除夕快乐!
⠄⠄⠄⠄⠄⠄⠄⣀⣤⣤⡄⠄⠄⠄⠄⠄⢀⣤⣶⠿⣿⡆⠄⠄
⠄⠄⠄⠄⠄⣀⣾⠋⠁⣸⡇⠄⠄⠄⢀⣴⡿⠋⠄⢀⣿⠇⣴⣦
⠄⠄⠄⠄⢰⡟⣡⠄⢠⣿⢁⣴⣦⠄⣾⣟⣤⠄⠄⣼⡟⢠⣿⣿
⠄⠄⠄⠄⠘⠛⠁⣴⡿⢣⣾⠏⣿⡆⠹⠟⠋⢀⣾⡟⠑⠿⣿⣿
⠄⠄⠄⠄⠄⢠⣾⠟⠁⣼⡏⢀⣿⠇⠄⠄⣰⣿⠏⠄⠄⠄⣿⣿
⠄⠄⠄⢀⣴⡿⠋⠄⠄⣿⡇⣸⡿⠄⣠⣾⡿⠋⠄⠄⠄⠄⣿⣿
⠄⢀⣴⡿⣋⣠⣤⣤⣄⡙⠿⠟⣡⣾⡿⠋⠄⠄⠄⠄⠄⠄⣿⣿
⣴⣿⣿⠿⠟⠛⠋⠉⠉⠉⢀⣴⣿⣟⣤⣤⣤⣤⣤⣄⡀⠄⣿⣿
⠉⠉⠄⠄⠄⠄⠄⠄⢀⣴⣿⣿⡿⠿⠛⠋⠉⠉⠉⠉⠁⠄⠛⠿
⠄⠄⠄⠄⠄⠄⠄⠄⠈⠛⠋⠁⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄
11 Feb, 2021 @ 3:24am 
節日快樂哦