数据结构day3

1.思维导图

2. 顺序表去重

/*----------顺序表的去重------------*/
void distinct_seq_list(seq_p L)
{
	if(L==NULL)
	{
		printf("参数为空,请检查\n");
		return;
	}
	if(empty_seq_list(L))
	{
		printf("顺序表已空,无法去重\n");
		return;
	}
	int i,j,k;
	for(i=0;i<L->len-1;i++)
	{
		for(j=i+1;j<L->len;j++)
		{
			if(L->arr[i]==L->arr[j])
			{
				for(k=j;k<L->len;k++)
				{
					L->arr[k]=L->arr[k+1];
				}
				L->len--;	
			}
		}
	}
}

 3.链表的创建

node_p create_link_list(void)
{
	node_p Head_node=(node_p)malloc(sizeof(node));
	if(Head_node==NULL)
	{
		printf("空间申请失败\n");
		return NULL;
	}
	Head_node->len=0;
	Head_node->next=NULL;
	return Head_node;
}

4.结点的创建

node_p create_link_node(datatype date)
{
	node_p New_node=(node_p)malloc(sizeof(node));
	if(New_node==NULL)
	{
		printf("空间申请失败\n");
		return NULL;
	}
	New_node->date=date;
	New_node->next=NULL;
	return New_node;
}

5.单链表的头插

void insert_head_link_list(node_p Head_node,node_p New_node,datatype newdate)
{
	if(Head_node==NULL||New_node==NULL)
	{
		printf("参数为空,请检查\n");
		return;
	}
	New_node->next=Head_node->next;
	Head_node->next=New_node;
	New_node->date=newdate;
	Head_node->len++;
}

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值