-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
求图最短路径 #144
base: master
Are you sure you want to change the base?
求图最短路径 #144
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
随机抽查到,给了一点建议,是否修改自己拿主意,非强制要求修改。
} | ||
//图的基本操作 | ||
|
||
Status LocateVex(MGraph *G,int v1,int v2) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
按照我们课件中的操作定义,LocateVex
应该是实现若G中存在顶点u,则返回该顶点在图中“位置” ;否则返回其它信息
,你这里实际的连线操作是不是用InsertArc
更合适?
// 在G中增添弧<v,w>,若G是无向的,
// 则还增添对称弧<w,v>。
InsertArc(&G, v, w);
{ | ||
int i; | ||
int j; | ||
//根据用例直接赋值。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
虽然就题论题你这里这样写是能得到正确答案的,但建议以后在实际应用编程时,尽量把这种参数配置类的工作交给调用者(函数)在调用函数时执行传参操作,代码的封装
和可复用
就会一点点积累起来了。
int j; | ||
|
||
MGraph Graph; | ||
CreateUDN(&Graph); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CreateUDN
有个返回值,再判断一下返回值就更有范儿了~
int i; | ||
int j; | ||
|
||
MGraph Graph; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
C/C++代码中,我们习惯于使用小写字母打头的单词表示一个变量
。大写字母开头的单词,我们的编码风格惯例是留给结构体
、函数名
、类
和方法
的。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
代码整体完成较为良好,注意仔细阅读作业要求。
查找节点:6 | ||
该元素存在,删除该节点,重新打印树 | ||
10 3 1 7 4 14 13 19 22 20 30 | ||
Program ended with exit code: 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
注意按照作业要求打印输出,数字之间使用", "分隔
root = Insert(root, 5); | ||
root = Insert(root, 19); | ||
root = Insert(root, 22); | ||
root = Insert(root, 30); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
建议使用一个创建树的函数,统一进行树的初始化插入操作
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- 需要修改:简单选择排序的实现。
- 二叉排序树作业修改通过
- 哈希表操作完成没有问题
- 建议修改:
- 使用有意义的变量名称提高代码可读性
- 自动格式化代码
if ( p[i] < p[j]&&(++s1)) | ||
{ | ||
swap(p[i],p[j]); | ||
s2+=3; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
注意再去理解简单选择排序的原理并修改此处的代码
No description provided.