Skip to content
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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

springwintersummer
Copy link
Contributor

No description provided.

Copy link
Contributor

@c4pr1c3 c4pr1c3 left a 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) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

虽然就题论题你这里这样写是能得到正确答案的,但建议以后在实际应用编程时,尽量把这种参数配置类的工作交给调用者(函数)在调用函数时执行传参操作,代码的封装可复用就会一点点积累起来了。

return OK;
}

typedef enum {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

所有代码都在一个文件里已经比较拥挤了,建议把所有的数据结构定义都前置在源代码文件的最开始处,起码不会像现在这样有点凌乱

return -1;
}
/*----------------���еIJ���------------*/
#define FALSE 0
Copy link
Contributor

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]);
Copy link
Collaborator

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;
Copy link
Collaborator

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++;
Copy link
Collaborator

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++;
}
Copy link
Collaborator

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个记录进行交换

  • 你这样写也能排序出来,但是已经脱离选择排序的初衷了

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants