• 博客访问： 69447
• 博文数量： 19
• 博客积分： 345
• 博客等级： 一等列兵
• 技术积分： 175
• 用 户 组： 普通用户
• 注册时间： 2012-10-29 13:37

2014年（1）

2013年（7）

2012年（11）

2012-12-14 18:53:51

#include
#include

typedef struct node
{
int a;
struct node * next;
} node_t;

void printf_node(node_t* h)
{
node_t* x;
x = h;
printf("print start!\n");
while(x != NULL)
{
printf("%d\n", x->a);
x = x->next;
}
printf("print end!\n");
}

node_t* find_a(node_t *h, int num)
{
node_t *x, *y, *pre;
x = h;
printf("find start!\n");
while(x != NULL && x->a != num)  //条件顺序不可改，
{
pre = y;
y = x;
if(x->a == num)
break;
x = x->next;
}
if(x == NULL) {
printf("no number!\n");
return NULL;
}
else {
printf("find it!\n");
return x;
}
}

node_t* modify_node(node_t *head, int num1, int num2)
{

while(temp = find_a(temp, num1))
temp->a = num2;
#if 0
while(temp != NULL)
{
if(temp->a == num1)
temp->a = num2;
temp = temp->next;//  printf_node(temp);
}
#endif

}

{
node_t *pre = NULL, *cur = NULL;

else {
while(cur != NULL && cur != anny)
{
pre = cur;
cur = cur->next;
}
if(cur->next !=NULL)
pre->next = cur->next;
else
pre->next = NULL;
}
if(cur)
{
free(cur);
cur = NULL;
anny = NULL;
}

}

{
while(p != NULL)
{
q = p;
p = p->next;
}
p = (node_t *)malloc(sizeof(node_t));
p->a = num;
p->next = NULL;

else
q->next = p;
}

{
node_t *pre = NULL, *cur = NULL, *nex = NULL;

cur = pre->next;
nex = cur->next;

pre->next = NULL;
cur->next = pre;

if(pre && cur && nex)
{
while(nex->next != NULL)
{
pre = cur;
cur = nex;
nex = nex->next;

cur->next = pre;
}
nex->next = cur;
}
else

}

int main(void)
{
node_t* head = NULL, *find = NULL;

return 0;
}

#if 0
{
node_t *p;
if(p){
free(p);
p = NULL;
}
}

{
node_t *pre = NULL, *cur = NULL, *nex = NULL;
{
while(nex != NULL)
{
pre = cur;
cur = nex;
nex = nex->next;
}
pre->next = NULL;
}
else
if(cur)
{
free(cur);
cur = NULL;
}
}
#endif

#include
#include

typedef struct node
{
int a;
struct node *next, *prev;
} node_t;

{
node_t* x;
printf("print start!\n");

do {
printf("%d\n", x->prev->a);
x = x->next;
printf("print end!\n");
}

{

p = (node_t *)malloc(sizeof(node_t));
p->a = num;

{
}
else {
}

}

{
node_t *pre, *cur, *nex;

printf("find start!\n");
while(num > 1)
{
cur = cur->next;
num--;
}
printf("find end!\n");

}

{
node_t *pre = NULL, *cur = NULL, *nex = NULL;

{
pre = cur->prev;
nex = cur->next;

pre->next = nex;
nex->prev = pre;

if(cur)
{
free(cur);
cur = NULL;
}
}

}

int main(void)
{