我无聊....来个全的....
/*****************************************************************
** HighlightCodeV3.0 software by yzfy(雨中飞燕) http://yzfy.org **
*****************************************************************/
typedef struct node{
int data;
node* next;
} node_m,*pnode_m;
pnode_m creatlist(pnode_m list,int size)
{
printf("please input the value of node: \n");
pnode_m tnode;
int value;
while(size>0)
{
scanf("%d",&value);
tnode = (pnode_m)malloc(sizeof(node_m));
tnode->next = NULL; tnode->data = value;
if(list==NULL) list = tnode;
else
{
tnode->next = list;
list = tnode;
}
--size;
}
return list;
}
void freelist(pnode_m list)
{
pnode_m pnode = list;
while(pnode!=NULL)
{
list = pnode->next;
free(pnode);
pnode = list;
}
}
pnode_m insertNode(pnode_m list,pnode_m node,const int cp)
{
pnode_m check = list,precheck=NULL;
int i=1;
for(;i<cp;++i) {precheck=check;check=check->next;}
if(precheck==NULL) {node->next=check;list=node;}
else
{
node->next = check;
precheck->next = node;
}
return list;
}
pnode_m deleteNode(pnode_m list,const int cp)
{
pnode_m check = list,precheck=NULL;
int i=1;
for(;i<cp;++i) { precheck=check;check=check->next;}
if(precheck==NULL) list=check->next;
else precheck->next = check->next;
free(check);
return list;
}
pnode_m exchangeNode(pnode_m list)
{
if(list==NULL) return NULL;
else
{
pnode_m precheck=NULL,check=list,checksuc=list->next;
for(;checksuc!=NULL; )
{
check->next=checksuc->next;
checksuc->next=check;
if(precheck!=NULL) precheck->next=checksuc;
else list=checksuc;
precheck=check;
check=check->next;
checksuc=(check==NULL?NULL:check->next);
}
return list;
}
}
void printlist(pnode_m list)
{
while(list!=NULL)
{
printf("%d->",list->data);
list=list->next;
}
putchar('\n');
}
----------------解决方案--------------------------------------------------------
我只能说,被飞燕的代码雷到了,而且彻彻底底地学习到了……
感谢飞燕…………
----------------解决方案--------------------------------------------------------
谁看见那个什么ioioc语言了。。我去打球回来就没有了。。。
----------------解决方案--------------------------------------------------------
貌似SW真正看明白我的代码了。。。呵呵
[color=white]
----------------解决方案--------------------------------------------------------
差距甚远......一样的思路,但我的那么繁杂....
----------------解决方案--------------------------------------------------------