摘要: #include <stdio.h>#include <stdlib.h>#include <time.h>const int ITEMNUM = 100;#define ElemType int//冒泡排序void Bubblesort(ElemType R[],int n,int &comp_num,int &move_num){int i,j,flag=1; //当flag为0,则停止排序ElemType temp;for(i = 0;i < n-1;i++){ //i表示趟数,最多n-1趟flag = 0;for(j = 1;j 阅读全文
posted @ 2012-06-17 14:12 蓬莱仙羽 阅读(495) 评论(0) 推荐(0) 编辑
摘要: //图 #include <stdio.h>#include <stdlib.h>#define MaxNum 100typedef char Type;//邻接矩阵类型定义typedef struct {Type vexs[MaxNum];int edges[MaxNum][MaxNum];int Vertex_num,edge_num;}MGraph;//邻接表类型定义typedef struct node{int adjvex;struct node *next;}EdgeNode;typedef struct{struct{ Type vertex; EdgeN 阅读全文
posted @ 2012-06-17 14:09 蓬莱仙羽 阅读(234) 评论(0) 推荐(0) 编辑
摘要: //链式结构#include <stdio.h>#include<stdlib.h> #include <malloc.h>#define MAXSIZE 1000typedef char ElemType;typedef struct LNode{//定义单链表结点类型ElemType data;struct LNode *next;}LinkList;void InitList(LinkList *&L){//带头结点的单链表L = (LinkList *)malloc(sizeof(LinkList));L -> next = NULL; 阅读全文
posted @ 2012-06-17 14:02 蓬莱仙羽 阅读(167) 评论(0) 推荐(0) 编辑
摘要: //对顺序表的操作#include<stdio.h>#include <stdlib.h>#include<malloc.h>#define MAXSIZE 1000typedef char ElemType;typedef struct{ElemType data[MAXSIZE];int length;}SqList;//初始化线性表void InitList(SqList*&L){L=(SqList*)malloc(sizeof(SqList));L->length=0;}//销毁线性表void DestoryList(SqList*&a 阅读全文
posted @ 2012-06-17 13:58 蓬莱仙羽 阅读(1007) 评论(0) 推荐(0) 编辑
摘要: #include <stdio.h>#include <stdlib.h>#define MaxSize 100typedef struct node{char data;/*此例中二叉树的结点采用字符类型*/struct node *lchild,*rchild;}NODE;/*按先序遍历序列创建二叉树的二叉链表*/NODE *crt_bt_pre(){NODE *bt;char ch;flushall();scanf("%c",&ch);if(ch == '0')bt = NULL;else{bt = new NODE;b 阅读全文
posted @ 2012-06-17 13:56 蓬莱仙羽 阅读(384) 评论(0) 推荐(0) 编辑