• 博客园logo
  • 会员
  • 周边
  • 新闻
  • 博问
  • 闪存
  • 众包
  • 赞助商
  • YouClaw
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
My Blog@github像少年啦飞驰
{关注大规模数据处理(MapReduce)J2EE等技术}
博客园    首页    新随笔    联系   管理    订阅  订阅
08 2011 档案
《编程之美》3.10分层遍历二叉树

摘要:#include<iostream>#include<vector>using namespace std;const int Max=30;class Node{public: Node(int d):data(d),left(NULL),right(NULL){} int data; Node *left; Node *right;};template<class T>class queue{public: queue(int i=Max):front(0),rear(0){Q=new T[Max];} void EnQueue(Node *p){Q[r 阅读全文
posted @ 2011-08-17 22:57 像少年啦飞驰 阅读(344) 评论(0) 推荐(0)
《编程之美》3.9重建二叉树

摘要:#includeusing namespace std;const int Max=20;struct Node{ Node *pLeft; Node *pRight; char chValue;};template class Stack{public: Stack(int s=Max):size(s),top(-1){a=new T[size];} ~Stack(){delete[] a;} void push(T x) { if(top-1) return a[top--]; } T getT() const { if(top!=-1) return a[top]; } boo... 阅读全文
posted @ 2011-08-16 21:57 像少年啦飞驰 阅读(134) 评论(0) 推荐(0)
《编程之美》3.9重建二叉树

摘要:#include<iostream>using namespace std;const int Max=20;struct Node{ Node *pLeft; Node *pRight; char chValue;};template <class T>class Stack{public: Stack(int s=Max):size(s),top(-1){a=new T[size];} ~Stack(){delete[] a;} void push(T x) { if(top<size-1) a[++top]=x; } T pop() { if(top> 阅读全文
posted @ 2011-08-16 21:57 像少年啦飞驰 阅读(928) 评论(0) 推荐(0)
还是畅通工程

摘要:题目参见:http://acm.hdu.edu.cn/showproblem.php?pid=1233Prim实现#include<iostream>using namespace std;const int Maxv=101;int map[Maxv][Maxv];int vset[Maxv];//顶点访问记录int lowcost[Maxv];int main(){ int sum; int n,i,j,cost; while(scanf("%d",&n) && n) { int m=n*(n-1)/2; while(m--) { s 阅读全文
posted @ 2011-08-13 22:50 像少年啦飞驰 阅读(262) 评论(0) 推荐(0)
最小生成树

摘要:普里姆算法(Prim)普里姆算法基本思想:从图中某个顶点V0开始,将V0到其他顶点的所有边当做候选边,重复以下步骤n-1次,使得其他n-1个顶点并入到树中:1、从候选边中挑选出权值最小的边输出,并将该边另一端相接的顶点V并入树中;2、考察所有剩余顶点Vi,如果(V,Vi)的权值比lowcost[Vi]小则用(V,Vi)的权值更新lowcost[Vi]。普里姆算法模板#define MAXN 101 //定义顶点的最大可达数int n, sum; //顶点数,权值和int map[MAXN][MAXN]; //以邻接矩阵存储权值void prim(){ int vset[MAXN]; //记录顶 阅读全文
posted @ 2011-08-13 22:45 像少年啦飞驰 阅读(457) 评论(0) 推荐(1)

博客园  ©  2004-2026
浙公网安备 33010602011771号 浙ICP备2021040463号-3