2008-02-21

A*寻路例子

关键字: 算法
如图,绿方块是起点,红方块终点;蓝方块是水(障碍物)。想像在图的周围加上边界,建立坐标系,x和y分别从1开始,则x取值[1,9],y取值[1,7],起点坐标(3,4),终点坐标(7,4);为简单起见,将坐标以一个整数标记:100 * y + x. 路径搜寻过程中,有一点与参考文章不同的是,障碍物的角被认为是可穿过的,只要穿过之后的坐标不是障碍物或边界。 参阅:http://www.cppblog.com/christanxw/archive/2006/04/07/5126.html 英文原文:http://www.gamedev.net/reference/articles/articl ...
2008-02-17

分硬币问题的递归解法

关键字: 算法
确定将一定数量的钱(以分为单位)转换成两角五分的硬币,一角硬币,五分和一分硬币的方法总数。 import java.util.Stack; public class Coin { private static int[] coins = {25,10,5,1}; private static Stack<Integer> roots =new Stack<Integer>(); private static void divide(int num){ for (int coin : coins){ ...
2008-02-14

坚持做做俯卧撑

关键字: 运动
又有很久没运动了。昨天做了几组俯卧撑,胸肌和肱三头肌疼的不轻。记录一下,看能坚持几天。 2008.2.13 最多的一次做15个 2008.2.14 最多的一次做14个 2008.2.15 最多的一次做15个 2008.2.16 5个(被大妞严重干扰了锻炼情绪) 2008.2.17 -1 2008.2.18 15
2008-02-14

卤水点豆腐

关键字: 饮食
1.煮小米时滴点油(豆油、花生油、香油),能防止其泡泡乱沸
2008-02-04

用Python抓网页上的图片

关键字: python
# -*- coding: utf-8 -*- """ some function by metaphy,2007-04-03,copyleft version 0.2 """ import urllib, httplib, urlparse import re import random """judge url exists or not,by others""" def httpExists(url): host, path = urlparse.urlsplit(url)[1:3] if ':' in host: # port ...
2008-02-04

算术表达式求值

关键字: 算法
词法分析package compile; /** * 词法分析:返回数字和操作符号的序列 * @author metaphy * 2007-6-14 */ public class Lexer { public static final String EOS = " " ; /*token之间的分隔符*/ public static final String DONE ="=" ; /*token结束的标记*/ private StringBuffer tokens = new StringBuffer(); private String expressi ...
2008-02-04

八皇后问题

关键字: 算法
public class Queens { private int[] queens = new int[8]; //解数组 private int[] colflag =new int[8]; //列冲突标记 private int[] flags1 = new int[15]; //对角线冲突标记 private int[] flags2 = new int[15]; //对角线冲突标记 private int roots ; private void trySet(int row){ for (int column=0; column < 8; col ...
metaphy
搜索本博客
我的相册
E4a25167-de99-3f5d-a292-f4dd7f86392a-thumb
theend
共 10 张
最近加入圈子
存档
最新评论