基本数据结构的操作
苏子散人
爱古风,爱代码。
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
链表的基本操作
#includeusing namespace std;typedef struct node{ int data; struct node *next;}Lnode;//头插法Lnode*creat1(){ Lnode*h,*p; h=(Lnode*)malloc(sizeof(Lnode)); h->next=NULL; int n; while(cin>>n&&n)原创 2016-04-03 22:51:29 · 417 阅读 · 0 评论 -
线性表的基本操作
#include#define maxsize 10using namespace std;typedef struct{ int v[maxsize]; int len;}sqlist;int insert(sqlist*L,int i,int elem){ if(L->len==maxsize){cout<<"溢出"<<endl;return 0;} else if(ima原创 2016-04-03 23:28:56 · 385 阅读 · 0 评论 -
单链表的逆转
#includeusing namespace std;typedef struct node{ int data; struct node *next;}Lnode;Lnode*create(){ Lnode*h,*p,*t; h=(Lnode*)malloc(sizeof(Lnode)); h->next=NULL; int n; t=h; while(cin>>n转载 2016-04-03 23:59:29 · 358 阅读 · 0 评论 -
print queue
关键是确定a[i]是否比后面的元素都大来判断它是否被打印。这里采用另外一个从大到小的数组,a[i]与之比较,如果相等则打印a[i]因为已经确保a[i]此时已是数组中最大的元素,否则进入队列末尾#include#include#includeusing namespace std;#define maxsize 150int a[maxsize];bool cmp(int x,int y){ return x>y;}struct point{ int x,y;}p[150];转载 2016-04-15 20:30:30 · 1892 阅读 · 0 评论 -
最大连续矩形面积(栈实现)
#include#includeusing namespace std;struct Node{ int w,h;};int main(){ int n; while(cin>>n&&n!=-1) { stacks; Node* rect=new Node[n+2]; int i; int total_w,cur_area,max_area=0; for(翻译 2016-05-22 09:53:33 · 794 阅读 · 0 评论 -
约瑟夫环的单链表实现
#includeusing namespace std;struct Child{ int no; Child *next;};class Joseph{ int n,m; Child *h;public: Joseph(int a,int b):n(a),m(b){} ~Joseph(){} void Create(); void seq();};void Jo原创 2016-06-12 19:54:41 · 558 阅读 · 0 评论 -
多项式相加单链表实现
#includeusing namespace std;struct PolyNode{ double coef; int exp; PolyNode *next;};class PolyClass{ PolyNode *head;//单链表的头结点指针public: PolyClass(); ~PolyClass(); void Disp(); void Creat原创 2016-06-12 23:45:57 · 849 阅读 · 0 评论 -
stl(list的用法)
//stl中的list就是一个双向链表,可以高效的进行插入删除元素,但不支持随机访问#include#includeusing namespace std;list list1,list2,list3;void Init(){ list1.push_back(1); list1.push_back(2); list1.push_back(3); list1.push_bac原创 2016-07-30 14:51:33 · 290 阅读 · 0 评论
分享