【发布时间】:2013-12-10 16:48:17
【问题描述】:
p 和 q 都是 node*。但我有点困惑这个作业代表什么?
struct node
{
int value;
struct node *next;
};
void rearrange(struct node *list)
{
struct node *p,*q;
int temp;
if (!list||!list->next) return;
p=list;
q=list->next;
while(q)
{
temp=p->value;
p->value=q->value;
q-value=temp;p=q->next;
q=p?p->next:0;
}
}
【问题讨论】:
-
你能发布确切的代码吗?
-
是问题的主题部分吗? q 是指向阳极的指针吗?并且您将 q 分配给 p?
-
您发布的代码中有一个额外的
}。我删除了它。但是,如果我引入了不准确之处,请随时更正我的编辑。
标签: c data-structures struct