#include <iostream>
using namespace std;
typedef struct Node
{
double val;
Node *next;
}node;
node* mycreat(double n)
{
node *head=NULL,*p=NULL,*sec=NULL;
head=(node*)malloc(sizeof(node));
p=head;
while(n--)
{
double v;
cin>>v;
sec=(node*)malloc(sizeof(node));
sec->val=v;
p->next=sec;
p=sec;
}
p->next=NULL;
return head;
}
void myprint(node *head)
{
double f=0;
node *p=NULL;
p=head->next;
while(p!=NULL)
{
if(f==0)
cout<<p->val;
else
cout<<" "<<p->val;
p=p->next;
f++;
}
cout<<endl;
}
node* copmycreat(node *head,double n)//copy函数
{
node *p=NULL;
node *cophead=NULL,*copp=NULL,*copsec=NULL;
cophead=(node*)malloc(sizeof(node));
copp=cophead;
p=head->next;//p由头指针下一个开始
while(n--)
{
copsec=
单链表的复制
最新推荐文章于 2024-08-01 18:44:55 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)