-
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
第七次作业广度优先遍历最短路径 #143
base: master
Are you sure you want to change the base?
第七次作业广度优先遍历最短路径 #143
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.
随机抽查到,给了一点建议,是否修改自己拿主意,非强制要求修改。
代码总体上是对照着课件中给出的伪代码规规矩矩的翻译
成了C代码,如果能再对照C语言的良好编码规范(例如我们这里给出的 #27 )去规规矩矩的组织编写
就更好了。
OVERFLOW | ||
}Status; | ||
|
||
Status CreateGraph(Graph *G) { |
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.
虽然就题论题你这里这样写是能得到正确答案的,但建议以后在实际应用编程时,尽量把这种参数配置类的工作交给调用者(函数)在调用函数时执行传参操作,代码的封装
和可复用
就会一点点积累起来了。
return OK; | ||
} | ||
|
||
typedef enum { |
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.
所有代码都堆
在一个文件里已经比较拥挤
了,建议把所有的数据结构定义都前置在源代码文件的最开始处,起码不会像现在这样有点凌乱
。
2017-1/zjc/第七次作业/main.c
Outdated
return -1; | ||
} | ||
/*----------------���еIJ���------------*/ | ||
#define FALSE 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.
前面刚刚定义过bool
型枚举变量,这里没必要再来用宏重复造轮子了。
for (i = 0; i < 5; i ++ ) | ||
{ | ||
if (SearchBST(T, b[i])) { | ||
printf("在数中找到 %d ! 现在把这个数从树中删除。\n", b[i]); |
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.
- 请看作业要求: 在本次PR中,应包含采用纯文本文件的方式保存的查找表使用上述测试用例产生的程序输出结果。
j--; | ||
move++; | ||
} | ||
R[j + 1] = temp; |
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.
- 这里是不是丢掉了1次移动次数的计算?下面的希尔排序也存在该问题
temp = R[j]; | ||
R[j] = R[j - 1]; | ||
R[j - 1] = temp; | ||
move++; |
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.
每一趟冒泡排序需进行i次比较,3i次移动
- 所以你的这里是不是应修改为
move+=3
R[i] = R[k]; | ||
R[k] = temp; | ||
move++; | ||
} |
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.
第i趟简单选择排序是指通过n−i次关键字的比较,从n−i+1个记录中选出关键字最小的记录,并与第i个记录进行交换
- 你这样写也能排序出来,但是已经脱离选择排序的初衷了
No description provided.