上一页 1 ··· 5 6 7 8 9

2013年9月26日

摘要: classQ{//队列类 private: inthead; inttail; intlength; boolflag; int*p; public: Q(intc,inta = 0,intb = 0,intd = 0){//构造函数 head = a; tail = b; length = c; flag = d; p = new int[c]; for(inti = 0;i < length;i++){ p[i] = 0; } } voidQprint()... 阅读全文
posted @ 2013-09-26 21:07 程序猿猿猿 阅读(156) 评论(0) 推荐(0) 编辑
摘要: struct node{ int Data; node *pre; node *next;};class linklist{ private: node *head; node *end; public: linklist(int D,int d){ head = new node; end = new node; head->pre = NULL; head->Data = D; head->next = end; end->pre = head; end->Data = d; end->ne... 阅读全文
posted @ 2013-09-26 21:05 程序猿猿猿 阅读(126) 评论(0) 推荐(0) 编辑
摘要: // Binary_search_tree.cpp : 定义控制台应用程序的入口点。//#include "stdafx.h"#include#include "stdio.h" #include "string.h" #include "stdlib.h"using namespace std;struct node{int key;node *p;node *left;node *right;};//二叉树节点//创造一颗树,这棵树只有一个节点,关键值为value,其他指针值为空(NULL)node *Tree 阅读全文
posted @ 2013-09-26 21:04 程序猿猿猿 阅读(201) 评论(0) 推荐(0) 编辑
摘要: primerp50左右extern如果初始化就定义变量,如果不初始化就是对变量的申明,表示要使用其他文件的该变量const声明变量要在其他文件中使用时,在使用和被使用的文件中都要声明 阅读全文
posted @ 2013-09-26 21:04 程序猿猿猿 阅读(89) 评论(0) 推荐(0) 编辑
摘要: /*This is the template of *.cpp files */#include#includeusing namespace std;int cut_rod(int *p,int n ){//暴力法求最优切割 if(n == 0) return 0; int q = -1; for(int i = 1;ip[i] + cut_rod(p,n-i)?q:p[i] + cut_rod(p,n-i); } return q;}int end_cut_rod(int *p,int n){//自底向上动态规划算法求最优切割方法的价值 以及切割方案 int *r = new int[n. 阅读全文
posted @ 2013-09-26 21:03 程序猿猿猿 阅读(530) 评论(0) 推荐(0) 编辑

2013年9月22日

摘要: /*在22世纪,科学家们发现智能居民生活在火星。火星人非常喜欢数学。每一年,他们将举行一次火星算术大赛(计算机) ,竞赛内容是计算两个100位数的和,使用时间最少的人获得冠军。今年,他们还邀请地球上的人参加竞赛。 ** 作为唯一代表地球,你发送给火星以展示人类的力量。幸运的是你带去的的笔记本电脑可以帮助您快速完成工作。现在剩下的问题只是写一个小程序来计算的两个给定数字的和。然而,在你开始写程序前要注意的是,火星人使用20进制数,因为它们通常有20个手指。 ** 输入: * * 给定一些火星数,每个一行。火星数是由0到9 ,和小写字母 a 至 j 组成的(小写字母a开始分别代表10 , 11 , 阅读全文
posted @ 2013-09-22 17:15 程序猿猿猿 阅读(368) 评论(0) 推荐(1) 编辑
摘要: /* */#include#includeusing namespace std;void is_zero(int n){ int m = (sqrt(8*n+1)-1)/2; int re = n - m*(m+1)/2; if(n == 1||re == 1){ cout<<"位置"<<n<<"该位置是1"<<endl; } else{ cout<<"位置"<<n<<"该位置是0"<<endl; }}int main 阅读全文
posted @ 2013-09-22 11:03 程序猿猿猿 阅读(816) 评论(0) 推荐(1) 编辑

2013年9月16日

摘要: ROUTE-COUNT(G) DFS(G) count = 0 return COUNT(G,s,t)COUNT(G,s,t) for each v in G:Adj[s] if v.d == t.d count = count + 1 else if v.d <t.d return count + COUNT(G,v,t) return count 阅读全文
posted @ 2013-09-16 22:29 程序猿猿猿 阅读(280) 评论(0) 推荐(0) 编辑
摘要: DFS(G) for each vertex u in G.V u.color = white u.pi = NIL time = 0 let A be a stack for each vertex u in G.V if u.color == white A.push(u) while A is not empty x = A.top() flag = 0 for each v in G:Adj[x] if v.color == white//遇到堆栈顶端元素相邻的节点有白色的都入栈 flag = 1 tim... 阅读全文
posted @ 2013-09-16 15:48 程序猿猿猿 阅读(1732) 评论(0) 推荐(0) 编辑

2013年9月10日

摘要: #include "stdafx.h"#includeusing namespace std;#define T 3struct B_tree_node{//B树的节点bool is_leaf;int n;int *key;struct B_tree_node *c; B_tree_node(){ n = 0; is_leaf = 1; }};B_tree_node B_tree_create_node(){ B_tree_node tem; tem.c = new B_tree_node[2*T]; tem.key = new int[2*T-1]; for(int i 阅读全文
posted @ 2013-09-10 09:17 程序猿猿猿 阅读(157) 评论(0) 推荐(0) 编辑
上一页 1 ··· 5 6 7 8 9

导航