帮忙把这段代码转成C语言的

来源:百度知道 编辑:UC知道 时间:2024/06/07 23:56:41
这段程序是我用C++写的,哪位高手能把它保存成.c扩展名的,并且能通过VC++6.0编译器。
请尽量别变动我的变量名字,比如LNode
谢谢
--------------------------------------
#include <stdio.h>
struct LNode
{
int num;
int data;
LNode *next;
};

void Free_List(LNode *head)
{
LNode *p,*q;
p=head->next;
while(p->next)
{
q=p;p=p->next;
delete(q);
}
head->next=NULL;
}
void Print_List(LNode *head)
{
if(!head)
{
printf("No List");
}
else
{
LNode *p;
p=head->next;
while(p)
{
printf("字号是%d,数字是%d\n",p->num,p->data);
p=p->next;
}
}
}
void Delete_List(LNode *head,int Key)
{
LNode *p=head->next,*q=head,*z;
while(p->next)
{
if(p->num==Key)
{
z=p;q->next=p->next;delete(z);break;

//没有细看,完全按照你的代码改的,但感觉你的代码有的地方还有问题
#include <stdio.h>
#include<malloc.h>
//#define NULL 0
#define SIZE sizeof(struct LNode)
struct LNode
{
int num;
int data;
struct LNode *next;
};

void Free_List(struct LNode *head)
{
struct LNode *p,*q;
p=head->next;
while(p->next)
{
q=p;p=p->next;
q=NULL;
}
head->next=NULL;
}
void Print_List(struct LNode *head)
{
if(!head)
{
printf("No List");
}
else
{
struct LNode *p;
p=head->next;
while(p)
{
printf("字号是%d,数字是%d\n",p->num,p->data);
p=p->next;
}
}
}
void Delete_List(struct LNode *head,int Key)
{
struct LNode *p=head->next,*q=head,*z;
while(p->next)
{
if(p->num==Key)
{