b2科目四模拟试题多少题驾考考爆了怎么补救
b2科目四模拟试题多少题 驾考考爆了怎么补救

没有前导节点的链表问题

电脑杂谈  发布时间:2020-05-28 02:18:57  来源:网络整理

带头结点的双循环链表_不带头结点的单链表_删除链表中的重复结点

没有前导节点的链表问题

不带头结点的单链表_删除链表中的重复结点_带头结点的双循环链表

 #include<stdio.h>
#include<stdlib.h>
typedef struct linknode
{
    int data;
    struct linknode *next;
} node;
node *Creat()
{
    node *head,*p,*s;
    int x,cycle=1;
    printf("Please input total number of data item (press 0 end):");
    head=(node* )malloc(sizeof(node));
    head->next=NULL;
    p=head;
    while (cycle) {
        scanf("%d",&x);
        if (x!=0) {
            s=(node*)malloc(sizeof(node));
            s->data=x;
            p->next=s;
            p=s;
        }
        else cycle=0;
    }
    p->next=NULL;
    p=head;
    head=head->next;
    free(p);
    return head;
}
void Delet(node *head,int i)
{
    int n=1;
    node *p;
    if (i==1){
        p=head;
        head=head->next;
        free(p);
    }
    else{
        while(head!=NULL){
        if(i==n+1) break;
            head=head->next;
            n++;
        }
        head->next=head->next->next;
    }
}
int main(void)
{
    int a;
    node *head,*p=NULL;
    head=Creat();
    printf("输入值a  \n");
    scanf("%d",&a);
        Delet(head,a);
    for(p=head;p!=NULL;p=p->next) printf("%d",p->data);
    return 0;
}

带头结点的双循环链表_删除链表中的重复结点_不带头结点的单链表

在删除没有头节点的链表时,程序的第一个数字是如何删除头节点. 请请上帝帮助修改我的程序. 非常感谢.

不带头结点的单链表_删除链表中的重复结点_带头结点的双循环链表

||集合||


本文来自电脑杂谈,转载请注明本文网址:
http://www.pc-fly.com/a/jisuanjixue/article-224712-1.html

    相关阅读
      发表评论  请自觉遵守互联网相关的政策法规,严禁发布、暴力、反动的言论

      • 陈冰川
        陈冰川

        美国欺负到门上了

        • 董志国
          董志国

          我也会选择守护目前来之不易的生活

      热点图片
      拼命载入中...