2014年3月5日

走迷宫(回溯)求路径长度/最短路径表

摘要: 时限:1000ms 内存限制:10000K 总时限:3000ms 描述:判断是否能从迷宫的入口到达出口输入: 先输入两个整数表示迷宫的行数m和列数n,再输入口和出口的坐标,最后分m行输入迷宫,其中1表示墙,0表示空格每个数字之间都有空格。输出: 若能到达终点,输出从起点到终点的(最短?)路径长度, 走不通时输出“No”输入样例:(行列坐标从0开始)12 121 810 71 1 1 1 1 1 1 1 1 1 1 11 0 0 0 0 0 0 1 0 1 1 11 0 1 0 1 1 0 0 0 0 0 11 0 1 0 1 1 0 1 1 1 0 11 0 1 0 0 0 0 0 1 0 0 阅读全文

posted @ 2014-03-05 18:54 IThinktan 阅读(4913) 评论(0) 推荐(0) 编辑

机器寻径引导算法(最短路径表)__深搜、栈

摘要: #include #include using namespace std;int Arr[30][30];//最大迷宫为30*30int Rownum=0,Colnum=0;//行列数int Beginrow,Begincol,Endrow,Endcol;//终点坐标int state=0;//迷宫走通与否状态struct Postion{ int X, Y; Postion(){}//构造函数 Postion(int X, int Y): X(X), Y(Y){}};void printPath(stack MinPATH);void printMat(int Arr[3... 阅读全文

posted @ 2014-03-05 18:28 IThinktan 阅读(551) 评论(0) 推荐(0) 编辑

2014年3月4日

机器寻径引导算法C#(最短路径表)

摘要: using System;using System.Collections;using System.Collections.Generic;using System.Linq;using System.Text;using GrapCity.Competition.CastleRush.Ai;using GrapCity.Competition.CastleRush.Ai.View;namespace _D01B6320_82D9_4D54_AFC9_C502657F2D99_{ public class AimStartOnPosition { //全局变量 ... 阅读全文

posted @ 2014-03-04 19:16 IThinktan 阅读(555) 评论(0) 推荐(0) 编辑

2013年6月21日

C#字符串(Sring)操作

摘要: //字符串访问 //string s = "ABCD"; //Console.WriteLine(s[0]);//第0位字符 //Console.WriteLine(s.Length);//字符串长度 //----------------------------------------------------------- //打散 //string s = "ABCD"; //char[] arr = s.ToCharArray();//将字符串打散,并放入字符数组中. //Console.WriteLine(arr[0]);//arr[0]=' 阅读全文

posted @ 2013-06-21 13:04 IThinktan 阅读(787) 评论(0) 推荐(0) 编辑

2012年11月3日

中序线索化二叉树

摘要: #include <stdio.h>#include <malloc.h>#define MaxSize 100typedef struct node { char data; int ltag,rtag;//增加的线索标记 struct node *lchild; struct node *rchild;} TBTNode;void CreateTBTNode(TBTNode * &b,char *str);//建立的二叉树void DispTBTNode(TBTNode *b);//输出二叉树TBTNode *CreaThread(TBTNode *b);/ 阅读全文

posted @ 2012-11-03 17:46 IThinktan 阅读(4920) 评论(1) 推荐(0) 编辑

无向图的深度优先生成树和广度优先生成树

摘要: #include <stdio.h>#include <malloc.h>#define MAXV 100//最大顶点个数int visited[MAXV];//全局数组typedef int InfoType;typedef struct { int edges[MAXV][MAXV];//邻接矩阵 int vexnum,arcnum; //顶点数,弧数} MGraph;//图的邻接矩阵类型typedef struct ANode { int adjvex; //该弧的终点位置 ... 阅读全文

posted @ 2012-11-03 16:50 IThinktan 阅读(13938) 评论(0) 推荐(0) 编辑

Prim算法求最小生成树

摘要: 数据结构书P189---图7.34#include <stdio.h>#define MAXV 100 //最大顶点个数#define INF 32767 //INF表示∞typedef struct { int edges[MAXV][MAXV];//邻接矩阵 int vexnum,arcnum; //顶点数,弧数} MGraph;//图的邻接矩阵类型void init(MGraph &g);//初始化邻接矩阵void DispMat(MGraph g);//输出邻接矩阵gvoid prim(MGraph g,int v);... 阅读全文

posted @ 2012-11-03 14:26 IThinktan 阅读(1560) 评论(1) 推荐(0) 编辑

哈夫曼编码_静态库

摘要: #include <stdio.h>#include <string.h>#define N 50 //叶子结点数#define M 2*N-1 //树中结点总数typedef struct//哈夫曼树的节点{ char data[5]; //结点存储的单词 int weight; //权重(该单词出现次数) int parent; //双亲结点 int lchild; //左孩子结点 int rchild; //右孩子结点} HTNode;typedef struct//哈... 阅读全文

posted @ 2012-11-03 12:21 IThinktan 阅读(1280) 评论(0) 推荐(0) 编辑

2012年11月2日

TSP问题_遗传算法(STL大量使用)

摘要: #include#include#include//random_shuffle();sort();lower_bound();#include#includeusing namespace std;typedef vector VI;typedef vector VVI;#define PB push_back //在vector尾部加入一个数据#define MP make_pair //1.将2个数据组合成一个数据//2.当一个函数需要返回2个数据的时候,可以选择pair//pair的实现是一个结构体,主要的两个成员变量是first、second //因为是使用struct不是class 阅读全文

posted @ 2012-11-02 10:48 IThinktan 阅读(751) 评论(0) 推荐(0) 编辑

单词倒排

摘要: 单词倒排(一)#include<stdio.h>#include<string.h>int main(){ int i,j; char a[20][20]={0},b[1][20]={0};//字符数组创建时就立即初始化为全0(即ASCI值0---对应字符'\0') for(i=0;i<20;i++) { int flag=0; for(j=0;;)//一个字符串的输入 { char C=getchar(); if(C=='\n') { flag=1; break; }... 阅读全文

posted @ 2012-11-02 09:54 IThinktan 阅读(1484) 评论(0) 推荐(0) 编辑

导航