SDUT 1138 数据结构上机测试2-1:单链表操作A

本文介绍了一个C语言程序,用于实现单链表的创建、展示和删除操作。程序通过`Creat`函数创建单链表,`Show`函数显示链表元素,`Delete`函数用于删除节点。主要涉及数据结构中的链表基础知识。
摘要由CSDN通过智能技术生成

//SDUT 1138 数据结构上机测试2-1:单链表操作A

#include <stdio.h>
#include <stdlib.h>

struct Node
{
int data;
struct Node *next;
};
void Show (struct Node *x);
struct Node *Creat(int n);
struct Node *Delete(struct Node *x,int n);

int main ()
{
int n;
struct Node *head,*heads;
scanf ("%d",&n);
head=Creat(n);

scanf ("%d",&n);
heads=Delete(head,n);

Show (head);
printf ("\n");
Show(heads);
return 0;

}
struct Node *Creat(int n)
{
struct Node *head,p,q;
int i=0;
head=(struct Node
)malloc (sizeof (struct Node));
if (head==NULL)
exit(0);
head->next=NULL;
head->data =n;
p=head;
q=head;
for (i=0;i<n;i++)
{
p=(struct Node
)malloc (sizeof(

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值