麻烦各位大神把这个程序从c++改成c

【编程】 麻烦各位大神把这个程序从c++改成c

--------------------------------------------

傻大方资讯为您精选的网友回复(供您参考):

[手机]#includeusing namespace std;#define A 6#define B 5typedef struct lnode{ int date; struct lnode *next;} lnode,*linklist;//创建单链表void Initlist(lnode *&p,int n){ linklist L,k; p=L=k=(lnode *)new lnode; cin>>p->date; for(int a=0;a { k=(lnode *)new lnode; cin>>k->date; k->next=L; L->next=k; L=k; }}//插入元素void listinsert(lnode *p,int nu,int z){ lnode *p1; p1=(lnode *)new lnode; p1->date=z; for(int x=0;x if(x==nu-1) { p1->next=p->next; p->next=p1; } else p=p->next;}//删除元素int listdelete(lnode *p,int nu){ int a; for(int x=0;x if(x==nu-2) { a=p->next->date; p->next=p->next->next; return a; } else p=p->next; return 0;}//查找元素lnode * listreserch(lnode *p,int n,int nu){ for(int a=0;a if(p->date==nu) return p; else p=p->next; cout<<"没有相等的数"< return NULL;}//lnode * listreserch1(lnode *p,int n,int nu){ for(int a=0;a if(p->date==nu) return p; else p=p->next; return NULL;}//合并单链表void hb(lnode *pa,int a,lnode *pb,int b){ lnode *pi; for(int z=0;z pa=pa->next; for(int x=0;x { pi=listreserch1(pa,a,pb->date); if(pi==NULL) { pa->next=pb; pa=pa->next; } if(x!=b-1) pb=pb->next; }}int _tmain(int argc, _TCHAR* argv[]){ int x; lnode *la,*lb,*al,*bl,*q;cout<<"请输入La:"< Initlist(la,A); cout<<"请输入Lb:"< Initlist(lb,B);listinsert(la,3,38); cout<<"插入后的La为:"< al=la; for(int a=0;a<=A;a++) { cout<date<<" "; al=al->next; } cout<listdelete(lb,4); cout<<"删除后Lb为:"< bl=lb; for(int a=0;a { cout<date<<" "; bl=bl->next; } cout<cout<<"请输入要寻找的数:"; cin>>x; q=listreserch(la,A+1,x); if(q!=NULL) cout<date<cout<<"合并后为:"< hb(la,A+1,lb,B-1); for(int a=0;a<10;a++) { cout<date<<" "; if(a!=9) la=la->next; } cout< system("pause");}

--------------------------------------------