随笔分类 - 数据结构
摘要:class LinkList{private class Node//创建节点类{public Object item;public Node next;}private Node head;private Node slider;private int count;public LinkList()//构造方法{clear();}public void clear()//清空链表{head = null;slider = null;count = 0;}public boolean isEmpty()//判断链表是否为空{return head==null;}public void goto
阅读全文
摘要:我们一般只是学过C/C++的数据结构,想必学C#的学生会疑惑,为什么C#没有数据结构呢,那我来告诉你,其实C#也是有数据结构的,只不过我们不了解罢了,经过我半天的编程,终于把C#的数据结构写出来了,也大大增加了我对数据结构的理解,在这里提供出来,共享学习,共同进步!using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace 控制台程序{ class CSharp数据结构 { public static void Main(string[] args) { Console.
阅读全文
摘要:#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
阅读全文
摘要://图 #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
阅读全文
摘要://链式结构#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;
阅读全文
摘要://对顺序表的操作#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
阅读全文
摘要:#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
阅读全文

浙公网安备 33010602011771号