⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 myhead.h

📁 数据结构基本
💻 H
字号:
#include<iostream.h>

struct node
{
	int data;
	node *next;
};


node *create(int *i,int n)
{
	node *head=NULL,*p;
	while(n-->0)
	{
		p=new node;
		p->data=*i++;
		p->next=head;
		head=p;
	}
	return head;
}      
//以上建立一个单链表

node *copy(node *r)
{
	node *p,*m,*head=NULL,*temp;   //设置临时指针变量 
	while(r)
	{
		m=new node;
		m->data=r->data;
		p=head;               //将开始结点变成终端结点
		while(p && p->data<m->data)
		{                   //每次循环将后一个结点变成开始结点
			temp=p;
			p=p->next;
		}
		if(p==head)
			head=m;
		else
			temp->next=m;
		m->next=p;
		r=r->next;
	}
	return head;//如是空表或单结点表,直接返回head 

}       
//以上对原链表进行逆置

void show(node *p)
{
	while(p)
		cout<<p->data<<" ",p=p->next;   //输出结果
	cout<<endl;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -