摘要: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title></title></head><body><script type="text/jav 阅读全文
posted @ 2011-03-27 14:32 山之松 阅读(198) 评论(0) 推荐(0)
摘要: 一个简单的题目:写一个形状类,再写一个三角形类和一个矩形类,用面向对象的方式实现,输出各个形状的边数和面积。三角形和矩形继承自形状类。源码如下:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title& 阅读全文
posted @ 2011-03-27 14:30 山之松 阅读(2293) 评论(0) 推荐(0)
摘要: namespace DSList{ //有向图接口类 public interface IDireGraph<T> { int GetNumOfVertex(); //获取顶点的数目 int GetNumOfArc(); //获取弧的数目 bool IsGvNode(GvNode<T> v); //v是否为图的顶点 int GetIndex(GvNode<T> v); //获得顶点V在顶点数组中的索引 void SetArc(GvNode<T> v1, GvNode<T> v2, int v); //在顶点v1和v2之间添加权值为v的 阅读全文
posted @ 2011-03-27 13:19 山之松 阅读(120) 评论(0) 推荐(0)
摘要: namespace DSList{ //有向图邻接表类(Directed Graph Adjacency List Class) public class DireGraAdjList<T> : IDireGraph<T> { private ALVexNode<T>[] adjList; public ALVexNode<T> this[int index] { get { return adjList[index]; } set { adjList[index] = value; } } public DireGraAdjList(GvNod 阅读全文
posted @ 2011-03-27 13:15 山之松 阅读(155) 评论(0) 推荐(0)
摘要: namespace DSList{ //有向图邻接矩阵类(Directed Graph Adjacency Matrix Class) public class DireGraAdjMatrix<T> : IDireGraph<T> { //Fields private GvNode<T>[] nodes; private int numArcs; private int[,] matrix; //Constructor public DireGraAdjMatrix(int n) { nodes = new GvNode<T>[n]; numA 阅读全文
posted @ 2011-03-27 13:14 山之松 阅读(342) 评论(0) 推荐(0)
摘要: namespace DSList{ //有向网邻接表类(Directed Net Adjacency List Class) public class DireNetAdjList<T> : IDireGraph<T> { //Field private ALVexNode<T>[] adjList; //Property public ALVexNode<T> this[int index] { get { return adjList[index]; } set { adjList[index] = value; } } //Construc 阅读全文
posted @ 2011-03-27 13:12 山之松 阅读(282) 评论(0) 推荐(0)
摘要: namespace DSList{ //无向网邻接表类(Undirected Net Adjacency List Class) public class NetAdjList<T> : IGraph<T> { //Field private ALVexNode<T>[] adjList; //vertex array //Property public ALVexNode<T> this[int index] { get { return adjList[index]; } set { adjList[index] = value; } } / 阅读全文
posted @ 2011-03-27 13:10 山之松 阅读(211) 评论(0) 推荐(0)
摘要: namespace DSList{ //有向网邻接矩阵类(Directed Net Adjacency Matrix Class) public class DireNetAdjMatrix<T> : IDireGraph<T> { //Fields private GvNode<T>[] nodes; //有向网的顶点数组 private int numArcs; //弧的数目 private int[,] matrix; //邻接矩阵数组 //Constructor public DireNetAdjMatrix(int n) { nodes = new 阅读全文
posted @ 2011-03-27 13:06 山之松 阅读(387) 评论(0) 推荐(0)
摘要: namespace DSList{ //无向网邻接矩阵类(Undirected Net Adjacency Matrix Class) public class NetAdjMatrix<T> : IGraph<T> { //Fields private GvNode<T>[] nodes; private int numEdges; private int[,] matrix; //Constructor public NetAdjMatrix(int n) { nodes = new GvNode<T>[n]; matrix = new in 阅读全文
posted @ 2011-03-27 12:57 山之松 阅读(174) 评论(0) 推荐(0)
摘要: namespace DSList{ //无向图邻接表类(Undirected Graph Adjacency List Class) public class GraphAdjList<T> : IGraph<T> { //Fields private ALVexNode<T>[] adjList; //Vertex array private int[] visited; //Auxiliary array of DFS() or BFS() //Property public ALVexNode<T> this[int index] { ge 阅读全文
posted @ 2011-03-27 12:54 山之松 阅读(293) 评论(0) 推荐(0)
摘要: namespace DSList{ //无向图邻接表的顶点结点类(Undirected Graph Adjacency List of Vertex Node) public class ALVexNode<T> { private GvNode<T> data; private AdjListNode<T> firstAdj; public GvNode<T> Data { get { return data; } set { data = value; } } public AdjListNode<T> FirstAdj { ge 阅读全文
posted @ 2011-03-27 12:52 山之松 阅读(260) 评论(0) 推荐(0)
摘要: namespace DSList{ //无向图邻接表的邻接结点类(Undirected Graph Adjacency List of Adjaceney Node) public class AdjListNode<T> { private int adjVex; private AdjListNode<T> next; private int weight; public int AdjVex { get { return adjVex; } set { adjVex = value; } } public AdjListNode<T> Next { g 阅读全文
posted @ 2011-03-27 12:49 山之松 阅读(187) 评论(0) 推荐(0)
摘要: namespace DSList{ //无向图邻接矩阵类(Undirected Graph Adjacency Matrix Class) public class GraphAdjMatrix<T> : IGraph<T> { //Fields private GvNode<T>[] nodes; //vertex array private int numEdges; //Edges number private int[,] matrix; //Matrix array //Constructor public GraphAdjMatrix(int n 阅读全文
posted @ 2011-03-27 12:46 山之松 阅读(354) 评论(0) 推荐(0)
摘要: namespace DSList{ //无向图邻接矩阵的顶点结点类(Undirected Graph Adjaceney Matrix of Vertex Node) public class GvNode<T> { private T data; public T Data { get { return data; } set { data = value; } } public GvNode(T val) { data = val; } }} 阅读全文
posted @ 2011-03-27 12:43 山之松 阅读(137) 评论(0) 推荐(0)
摘要: namespace DSList{ public interface IGraph<T> { int GetNumOfVertex(); //获取顶点的数目 int GetNumOfEdge(); //获取边的数目 bool IsGvNode(GvNode<T> v); //v是否为图的顶点 int GetIndex(GvNode<T> v); //获得顶点V在顶点数组中的索引 void SetEdge(GvNode<T> v1, GvNode<T> v2, int v); //在顶点v1和v2之间添加权值为v的边 void DelE 阅读全文
posted @ 2011-03-27 01:23 山之松 阅读(80) 评论(0) 推荐(0)
摘要: namespace DSList{ public class HuffmanTree { private HfmCode[] hfmCode; private HfmNode[] hfmNode; public HfmCode getHfmCode(int index) { return hfmCode[index]; } public void setHfmCode(int index,HfmCode hfcode) { hfmCode[index] = hfcode; } public HfmNode getHfmNode(int index) { return hfmNode[index 阅读全文
posted @ 2011-03-27 01:16 山之松 阅读(185) 评论(0) 推荐(0)
摘要: namespace DSList{ public class HfmNode { private int flag; //标记 private int weight; //权植 private int lChild; //左孩子下标 private int rChild; //右孩子下标 private int parent; //双亲结点下标 public int Flag { get { return flag; } set { flag = value; } } public int Weight { get { return weight; } set { weight = value 阅读全文
posted @ 2011-03-27 01:13 山之松 阅读(128) 评论(0) 推荐(0)
摘要: namespace DSList{ public class BinaryTree<T> where T:IComparable<T> { //Field private TreeNode<T> head; //Property public TreeNode<T> Head { get { return head; } set { head = value; } } //Constructors public BinaryTree(T val, TreeNode<T> lc, TreeNode<T> rc) { Tree 阅读全文
posted @ 2011-03-27 01:11 山之松 阅读(186) 评论(0) 推荐(0)
摘要: namespace DSList{ public class TreeNode<T> { private T data; private TreeNode<T> lChild; private TreeNode<T> rChild; public T Data { get { return data; } set { data = value; } } public TreeNode<T> LChild { get { return lChild; } set { lChild = value; } } public TreeNode<T& 阅读全文
posted @ 2011-03-27 01:09 山之松 阅读(122) 评论(0) 推荐(0)
摘要: namespace DSList{ public class StringDS { //Field private char[] data; //Properties public char this[int index] { get { return data[index]; } set { data[index] = value; } } //Constructors public StringDS(char[] arr) { data = new char[arr.Length]; for (int i = 0; i < arr.Length; i++) { data[i] = a 阅读全文
posted @ 2011-03-27 01:06 山之松 阅读(110) 评论(0) 推荐(0)
摘要: namespace DSList{ public class LinkQueue<T> : IQueue<T> { //Fields private Node<T> front; private Node<T> rear; private int count; //Properties public Node<T> Front { get { return front; } set { front = value; } } public Node<T> Rear { get { return rear; } set { r 阅读全文
posted @ 2011-03-27 01:03 山之松 阅读(99) 评论(0) 推荐(0)
摘要: namespace DSList{ public class CSeqQueue<T> : IQueue<T> { //Fields private int maxsize; private T[] data; private int front; private int rear; private int count; //Properties public T this[int index] { get { return data[index]; } set { data[index] = value; } } public int Maxsize { get { 阅读全文
posted @ 2011-03-27 01:01 山之松 阅读(233) 评论(0) 推荐(0)
摘要: namespace DSList{ public interface IQueue<T> { int GetLength(); //求队列的长度 void Clear(); //清空操作 bool IsEmpty(); //判断是否为空 void In(T item); //入队操作 T Out(); //出队操作 T GetFront(); //取队头元素 }} 阅读全文
posted @ 2011-03-27 00:58 山之松 阅读(106) 评论(0) 推荐(0)
摘要: namespace DSList{ public class LinkStack<T> : IStack<T> { //Fields private Node<T> top; //Top reference indicator private int num; //Node quantity //Properties public Node<T> Top { get { return top; } set { top = value; } } public int Num { get { return num; } set { num = val 阅读全文
posted @ 2011-03-27 00:55 山之松 阅读(122) 评论(0) 推荐(0)
摘要: namespace DSList{ public partial class SeqStack<T> : IStack<T> where T:IComparable<T> { /// <summary> /// fields /// </summary> private int maxsize; private T[] data; private int top; /// <summary> /// properties /// </summary> public int Maxsize { get { ret 阅读全文
posted @ 2011-03-27 00:50 山之松 阅读(153) 评论(0) 推荐(0)
摘要: namespace DSList{ public interface IStack<T> { int GetLength(); //求栈的长度 bool IsEmpty(); //判断栈是否为空 void Clear(); //清空操作 void Push(T item); //入栈操作 T Pop(); //出栈操作 T GetTop(); //取栈顶元素 }} 阅读全文
posted @ 2011-03-27 00:48 山之松 阅读(86) 评论(0) 推荐(0)
摘要: namespace DSList{ public partial class DbLinkList<T> : IListDS<T> where T : IComparable<T> { private DbNode<T> head; //Head reference domain //Head property public DbNode<T> Head { get { return head; } set { head = value; } } //Constructor public DbLinkList() { head = n 阅读全文
posted @ 2011-03-27 00:43 山之松 阅读(124) 评论(0) 推荐(0)
摘要: namespace DSList{ public class DbNode<T> { /// <summary> /// fields /// </summary> private DbNode<T> prev; //Previous reference domain private T data; //Data domain private DbNode<T> next; //Next reference domain /// <summary> /// properties /// </summary> p 阅读全文
posted @ 2011-03-27 00:40 山之松 阅读(167) 评论(0) 推荐(0)
摘要: namespace DSList{ public partial class LinkList<T> : IListDS<T> where T:IComparable<T> { //fields private Node<T> head; //property public Node<T> Head { get { return head; } set { head = value; } } //constructor public LinkList() { head = null; } //base methods public i 阅读全文
posted @ 2011-03-27 00:37 山之松 阅读(110) 评论(0) 推荐(0)
摘要: namespace DSList{ public class Node<T> { // fields private T data; //Data domain private Node<T> next; //Next reference domain // properties public T Data { get { return data; } set { data = value; } } public Node<T> Next { get { return next; } set { next = value; } } // constructo 阅读全文
posted @ 2011-03-27 00:31 山之松 阅读(165) 评论(0) 推荐(0)
摘要: namespace DSList{ public partial class SeqList<T> : IListDS<T> where T:IComparable<T> { //fields private T[] data; private int last; private int maxsize; //properties public T this[int index] { get { return data[index]; } set { data[index] = value; } } public int Last { get { retur 阅读全文
posted @ 2011-03-27 00:26 山之松 阅读(1146) 评论(0) 推荐(0)
摘要: namespace DSList{public interface IListDS<T>{int GetLength(); //求长度bool IsEmpty(); //判断线性表是否为空void Clear(); //清空操作void Append(T item); //追加操作void Insert(int pos, T item); //插入操作T Remove(int pos); //删除操作T GetElem(int pos); //取表元int Locate(T item); //按值查找}} 阅读全文
posted @ 2011-03-27 00:22 山之松 阅读(144) 评论(0) 推荐(0)