抽象到队列上说,有队头,队尾,要想入队,只能从队尾加,出队,只能从队头走。
//和栈一样,它常见的两种存储是顺序存储和链式存储。
总之:
队列,先进先出;
栈,先进后出;
链表。。。实在听不懂是干嘛的。。
队列:
队头 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);
//};