上一页 1 ··· 5 6 7 8 9 10 11 12 13 ··· 17 下一页
摘要: //map类型的使用和实数比较//(1)题目要求浮点数只有一位,所以可以采取乘10将结果赋给一个整数,然后进行整数之间的比较//(2)a < b - epsilon, a <=b as a <= b + epsilon, and a = b becomes |a-b| < epsilon. epsilon取10-9#include <map>#include &... 阅读全文
posted @ 2010-05-04 13:26 北海小龙 阅读(141) 评论(0) 推荐(0) 编辑
摘要: //经典的深度优先搜索#include <iostream>using namespace std;#define arraysize 21int data[arraysize];//存储结果bool final[arraysize];//标记该节点是否已经被搜索//素数表,用于存储是否是素数,从0开始,1代表是素数int primelist[38] = {0,0,1,1,0,1,0,... 阅读全文
posted @ 2010-05-04 13:26 北海小龙 阅读(645) 评论(1) 推荐(1) 编辑
摘要: #include <iostream>#include <algorithm>#include <string.h>//引入strcmp和strlen的头文件using namespace std;long int target;char alpstr[13];int length;//将字符从大到小进行排序(本题的关键)/*int cmp(const void... 阅读全文
posted @ 2010-05-03 11:38 北海小龙 阅读(350) 评论(0) 推荐(0) 编辑
摘要: //朴素的广度优先搜索#include <iostream>#include <string>using namespace std;#define arraysize 10typedef struct node{int col;int row;int step;//记录该点到原点的距离}node;node myqueue[100];bool hash[arraysize]... 阅读全文
posted @ 2010-05-02 22:48 北海小龙 阅读(218) 评论(0) 推荐(0) 编辑
摘要: //重点理解:关键抽象成最小生成树问题及二维字符串数组的使用#include <stdio.h>#include <string.h>#define arraysize 2001char truck[arraysize][8];//定义字符串二维数组int dis[arraysize][arraysize];bool final[arraysize];int d[array... 阅读全文
posted @ 2010-04-30 22:31 北海小龙 阅读(248) 评论(0) 推荐(0) 编辑
摘要: //朴素的最小生成树:prim算法实现#include <stdio.h>#include <string.h>#include <math.h>#define arraysize 1001typedef struct node{int x;int y;}node;node nodes[arraysize];double dis[arraysize][array... 阅读全文
posted @ 2010-04-30 22:31 北海小龙 阅读(165) 评论(0) 推荐(0) 编辑
摘要: #include <stdio.h>#include <math.h>#include <algorithm>using namespace std;#define arraysize 751#define array 1001//已修建的路int xi[arraysize];int yi[arraysize];int final[arraysize];int ... 阅读全文
posted @ 2010-04-30 22:30 北海小龙 阅读(206) 评论(0) 推荐(0) 编辑
摘要: //最小生成树:Prim#include <stdio.h>#include <string.h>#define arraysize 28int dis[arraysize][arraysize];bool final[arraysize];int d[arraysize];int n;int maxData = 0x7fffffff;void Prim(){int i;i... 阅读全文
posted @ 2010-04-30 22:30 北海小龙 阅读(243) 评论(0) 推荐(0) 编辑
摘要: //最小生成树:Prim算法实现,不要使用Kruskal算法,否则会出现超时#include <stdio.h>#include <math.h>#include <string.h>#define nodesize 1001typedef struct node{int x;int y;}node;//对于nodes和record的含义不同,nodes指的是点... 阅读全文
posted @ 2010-04-30 22:29 北海小龙 阅读(265) 评论(0) 推荐(0) 编辑
摘要: //解题思路:最小生成树Prim算法实现,注意将已修建的路的距离置为0#include <stdio.h>#include <string.h>#define arraysize 101int maxData = 0x7fffffff;int dis[arraysize][arraysize];bool final[arraysize];int d[arraysize];i... 阅读全文
posted @ 2010-04-30 22:28 北海小龙 阅读(280) 评论(0) 推荐(0) 编辑
上一页 1 ··· 5 6 7 8 9 10 11 12 13 ··· 17 下一页