
数据结构
phytn
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
逆序创建单链表
#include typedef int A; typedef struct LNode { A data; struct LNode *next; }LNode,*LinkList; void CreateList(LinkList &L,A a[],int n) { int i; L=NULL; for(i=n-1;i>=0;i--) { LinkLi原创 2014-07-27 09:42:23 · 1149 阅读 · 0 评论 -
括号配对问题
#include #include int main() { int n,t,low,high,i; char a[10000],s[10000]; scanf("%d",&n); while(n--) { scanf("%s",a); t=strlen(a); low=0; high=0; for(i=0;i<t;i++) { switch(a[i])原创 2014-11-27 21:24:42 · 587 阅读 · 0 评论 -
插入结点的操作(单链表)
#include typedef struct LNode { int data; struct LNode *next; }LNode,*LinkList; void ListInsert(LinkList &L,LNode *p,LNode *s) { LinkList q; if(p==L) { s->next=L; L=s; } else原创 2014-07-27 09:55:22 · 758 阅读 · 0 评论 -
求新的集合 A=AUB(顺序表)
#include typedef int A; const int LIST_INIT_SIZE=100; const int LISTINCREMENT=10; typedef struct { A *elem; int length; int listsize; int incrementsize; }List; void InList(List &L,int原创 2014-07-27 09:30:22 · 966 阅读 · 0 评论 -
(顺序表)判断两集合是否相等
#include typedef int A; const int LIST_INIT_SIZE=100; const int LISTINCRMENT=10; typedef struct { A *elem; int Length; int Listsize; int incrementsize; }List; void InitList(List &L,int原创 2014-07-27 09:40:30 · 993 阅读 · 0 评论 -
La=LaULb (循环链表)
#include typedef struct LNode { int data; struct LNode *next; }LNode,*LinkList; void union1(LinkList &La,LinkList &Lb) { LinkList qb; LinkList pa=La->next->next; LinkList pb=Lb->next->n原创 2014-07-27 10:12:43 · 474 阅读 · 0 评论 -
查找元素的操作(单链表)
#include typedef struct LNode { int data; int length ; struct LNode *next; }LNode,*LinkList; int count = 0 ; LNode * LocateElem(LinkList L,int e) { LinkList p=L; p->length = 0 ; whil原创 2014-07-27 09:53:24 · 1578 阅读 · 0 评论 -
(顺序有序表)插入元素
#include typedef int A; const int LIST_INIT_SIZE=100; const int LISTINCRMENT=10; typedef struct { A *elem; int Length; int Listsize; int incrementsize; }SqList; void InitList(SqList &L,原创 2014-07-27 10:05:41 · 875 阅读 · 0 评论 -
插入结点(双向链表)
#include typedef struct DuLNode { int data; struct DuLNode *prior; struct DuLNode *next; }DuLNode,* DuLinkList; void ListInsert(DuLinkList &L,DuLNode *p,DuLNode *s) { s->prior=p->prior;原创 2014-07-27 10:03:04 · 490 阅读 · 0 评论 -
顺序表中基本操作的实现
#include typedef int A; const int LIST_INIT_SIZE=100; const int LISTINCREMENT=10; typedef struct { A *elem; int length; int listsize; int incrementsize; }Sqlist; //初始化操作 void InitList_原创 2014-07-27 09:29:44 · 1121 阅读 · 0 评论 -
La=LaULb (单链表)
#include typedef struct LNode { int data; struct LNode *next; }LNode,*LinkList; void union1(LinkList &La,LinkList &Lb) { LinkList s,p,pre; if(!La) La=Lb; else { while(Lb) {原创 2014-07-27 09:59:32 · 550 阅读 · 0 评论 -
删除结点的操作(单链表)
#include typedef struct LNode { int data; struct LNode *next; }LNode,*LinkList; void ListDelete(LinkList &L,LNode *p,int &e) { LinkList q; if(p==L) L=p->next; else { q=L; whi原创 2014-07-27 09:56:13 · 704 阅读 · 0 评论 -
逆置单链表
#include typedef struct LNode { int data; struct LNode *next; }LNode,*LinkList; void InvertLinkedList(LinkList &L) { LinkList p=L; L=NULL; while(p!=NULL) { LinkList s=p; p=p->ne原创 2014-07-27 09:44:29 · 422 阅读 · 0 评论 -
删除Lb重复的数,用La输出(顺序表)
#include typedef int A; const int LIST_INIT_SIZE=100; const int LISTINCRMENT=10; typedef struct { A *elem; int Length; int Listsize; int incrementsize; }List; void InitList(List &L,int原创 2014-07-27 09:36:51 · 784 阅读 · 0 评论 -
删除重复的数(顺序有序表)
#include const int LIST_INIT_SIZE=100; const int LISTINCRMENT=10; typedef int A; typedef struct { A *elem; int Length; int Listsize; int incrementsize; }SqList; void InitList(SqList &L,原创 2014-07-27 10:08:28 · 559 阅读 · 0 评论 -
删除结点 (双向链表)
#include typedef struct DuLNode { int data; struct DuLNode *prior; struct DuLNode *next; }DuLNode,* DuLinkList; void ListDelete(DuLinkList &L,DuLNode *p,int &e) { e=p->data; p->prior->n原创 2014-07-27 10:04:56 · 423 阅读 · 0 评论 -
求长度(单链表)
#include typedef struct LNode { int data; struct LNode *next; }LNode,*LinkList; int ListLength(LinkList L) { LinkList p=L; int k=0; while(p!=NULL) { k++; p=p->next; } return原创 2014-07-27 09:45:41 · 5906 阅读 · 0 评论 -
卡片游戏
桌上有一叠牌,从第一张牌(即位于顶面的牌)开始从上往下依次编号为1~n。当至少还剩两张牌时进行以下操作:把第一张牌扔掉,然后把新的第一张放到整叠牌的最后。输入n,输出每次扔掉的牌,以及最后剩下的牌。 输入:7 输出: 1 3 5 7 4 2 6 #include #include using namespace std; queue q; int main() { int n; sc原创 2015-07-05 11:36:42 · 751 阅读 · 0 评论