小白初探---栈,队列,链表--从入门到放弃

抽象到队列上说,有队头,队尾,要想入队,只能从队尾加,出队,只能从队头走。

//和栈一样,它常见的两种存储是顺序存储和链式存储。

总之:

队列,先进先出;

栈,先进后出;

 

 

链表。。。实在听不懂是干嘛的。。

 

 

队列:

队头 front;

队长 size;

弹出第一个 pop;

进队 push;

栈:

栈顶 top;

栈长 size;

弹出 pop;

进栈 push;

//栈的基本操作:

//栈空isEmpty:

//栈满isFull:

//进栈push:

//出栈pop:

//取栈顶top:

//栈的大小:size:

链表的用法详解:

//#include<stdio.h>

//#include<stdlib.h>

//struct node

//{

//   int data;

//   struct node *next;

//};

//int main()

//{

//   int n, i, j, t;

//   int flag = 0, k = 0, x;

//   struct node *head, *add, *p, *q, *r,*t1;

//   head = (struct node*)malloc(sizeof(struct node));

//   scanf("%d", &n);

//   head->next = NULL;

//   t1 = head;

//   for (i = 1; i <= n; i++)

//   {

//       if (i == 1)

//       {

//            scanf("%d",&head->data);

//       }

//       else

//       {

//            add = (structnode*)malloc(sizeof(struct node));

//            scanf("%d",&add->data);

//            add->next = NULL;

//            t1->next = add;

//            t1 = add;

//       }

//       

//   }

//   printf("%d\n", n);

//   p = head;

//   q = head->next;

//   while (q)

//   {

//       r = q->next;

//       q->next = p;

//       p = q;

//       q = r;

//   }

//   head->next = NULL;

//   head = p;

//   q = head;

//   

//   while (q!=NULL)

//   {

//       printf("%d ", q->data);

//       q = q->next;

//   }

//   

//   printf("\n");

//   p = head;

//   

//   while (p)

//   {

//       r = p;

//       q = p->next;

//       while (q)

//       {

//            if (q->data == p->data)

//            {

//               n--;

//                r->next = q->next;

//                q = q->next;

//            }

//            else

//            {

//                q = q->next;

//                r = r->next;

//            }

//           

//       }

//       p = p->next;

//       

//   }

//   printf("%d\n", n);

//   q = head;

//   

//   while (q != NULL)

//   {

//       printf("%d ", q->data);

//       q = q->next;

//   }

//   printf("\n", n);

//   return 0;

//}

//struct node *head;

//struct node *creat(int n)

//{

//   int i;

//   struct node *tail,*p;

//   head=(struct node *)malloc(sizeof(struct node));

//   head->next=NULL;

//   tail=head;

//   for(i=0;i<n;i++)

//   {

//       p=(struct node *)malloc(sizeof(struct node));

//       scanf("%d",&p->data);

//       p->next=NULL;

//       tail->next=p;

//       tail=p;

//   }

//   return(head);

//};

 

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值