📄 test02_1.cpp
字号:
// test02_1}
#include "linklist.h"
void copy1(link l,link &l1)
{
link p,r,s;
p=l->next;
l1=(link)malloc(sizeof(struct node));
r=l1;
while (p!=NULL){
s=(link)malloc(sizeof(struct node));
s->data=p->data;
r->next=s;
r=s;
p=p->next;
}
r->next=NULL;
}
void copy2(link l,link &l1)
{
if (l!=NULL){
l1=(link)malloc(sizeof(struct node));
l1->data=l->data;
copy2(l->next,l1->next);
}else l1=NULL;
}
void main()
{
link l,l1,l2;
load_hsllist(l);
comput_sllist_card(l,50,100);
disp_hsllist("Sllist",l);
getch();
copy1(l,l1);
comput_sllist_card(l1,50,250);
disp_hsllist("copy1",l1);
getch();
copy2(l,l2);
comput_sllist_card(l2,50,400);
disp_hsllist("copy2",l2);
getch();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -