更新时间:2023-02-05 22:54:30
while(no_of_nodes>0)
{
if(no_of_nodes>=1)
{
if
子句是多余的,因为如果no_of_nodes
小于1,则循环将无法继续.
另外,创建节点时,应将其初始化,以使p->next
为NULL.仅当在链中添加下一个节点时,才应将新节点的地址设置为p->next
The if
clause is redundant as the loop cannot continue if no_of_nodes
is less than 1.
Also, when you create a node you should initialise it such that p->next
is NULL. Only when you add the next node in the chain should you set the address of the new one into p->next