随笔分类 -  数据结构基本实验

队列表达式求值
摘要:#include <iostream>#include<iomanip>#include <string>#include <sstream>#include<queue>using namespace std;bool fun(char a){ if(a=='*'||a=='/') return true; return false;}double fun1(double i,double j,char a){ if(a=='*') return i*j; else if(a== 阅读全文
posted @ 2013-02-25 19:47 叶城宇 阅读(406) 评论(0) 推荐(0)
哈夫曼树
摘要:#include "stdafx.h"#include<iostream>using namespace std;#include<fstream>#include<string>typedef struct {char date; int weight; int parent,lchild,rchild;}Htnode,*huffmanTree;typedef char* * huffmancode;void fun(Htnode *p,char a,int b){ p->date=a; p->weight=b; p-> 阅读全文
posted @ 2013-02-25 19:44 叶城宇 阅读(400) 评论(0) 推荐(0)
二叉树的遍历
摘要://二叉树的基本操作#include<iostream>using namespace std;typedef char Telemtype;typedef struct bitnode { Telemtype date; int mark; bitnode *lchild,*rchild;}*bitree;int initbitree(bitree &T){ T=NULL; return 1; } int createbitree (bitree &T){ //按先序次序输入二叉树中节点的值(一个字符),空格字符表示空树; //构造二叉树表表示的二叉树T. cha 阅读全文
posted @ 2013-02-25 19:39 叶城宇 阅读(181) 评论(0) 推荐(0)
迷宫问题
摘要://链表栈#include "stdafx.h"#include<iostream>using namespace std;typedef struct{ int line; int count; int dir;}Elemtype;typedef struct s{ Elemtype elem ; s* next; }s;//链表栈的结点类型为结构体;void initstack(s*&base){ base=(s*) malloc (sizeof(s)); base->next=NULL;}void push(s*&base ,Elem 阅读全文
posted @ 2013-02-25 19:37 叶城宇 阅读(252) 评论(0) 推荐(0)
约瑟夫环
摘要://循环链表.h#include "stdafx.h"#include<iostream>using namespace std;typedef int Elemtype[2] ;typedef struct l { Elemtype elem; struct l* next;}l;//链表的结点类型为结构体;l* r,*f;bool initlist(l*&a){ a=(l*)malloc(sizeof(l)); if(!a)return false; (*a).next=a;r=a;f=a; return true;}//键头结点;void link 阅读全文
posted @ 2013-02-25 19:34 叶城宇 阅读(181) 评论(0) 推荐(0)
队列的基本操作
摘要://队列的链式存储结构(还没写遍历)==============#include<iostream>using namespace std;typedef struct qnode{ int data; struct qnode *next ;}qnode,*queueptr;typedef struct{ queueptr front; queueptr rear;}linkqueue;///////////////////int initqueue(linkqueue &q){ q.front=q.rear=(queueptr)malloc (sizeof(qnode) 阅读全文
posted @ 2013-02-23 14:55 叶城宇 阅读(200) 评论(0) 推荐(0)
图的遍历
摘要:#include<iostream>using namespace std;typedef struct qnode{ int data; struct qnode *next ;}qnode,*queueptr;typedef struct{ queueptr front; queueptr rear;}linkqueue;///////////////////int initqueue(linkqueue &q){ q.front=q.rear=(queueptr)malloc (sizeof(qnode)); if(!q.front) return 0; q.fron 阅读全文
posted @ 2013-02-23 14:52 叶城宇 阅读(179) 评论(0) 推荐(0)