资源简介
以1号蜂窝为点,其他蜂窝按照逆时针排列,求任意两个蜂窝间最短路径

代码片段和文件信息
package main;
public class CalRoutes {
public CalRoutes()
{
}
int start=1;
int end=1;
int laps=0;
int leap=6;
int xjump=1;
int yjump=2;
int zjump=3;
int xbase=1;
int ybase=1;
int zbase=1;
public int CaltheDistance(int posaint posb)
{
Coordinates coorposa=new Coordinates();
Coordinates coorposb=new Coordinates();
GetTheCoordinates(posa coorposa);
GetTheCoordinates(posb coorposb);
int x=coorposa.getX()-coorposb.getX();
int y=coorposa.getY()-coorposb.getY();
int z=coorposa.getZ()-coorposb.getZ();
int distanc=GetRouts(x y z);
return distanc;
}
void Init()
{
start=1;
end=1;
laps=0;
leap=6;
xjump=1;
yjump=2;
zjump=3;
xbase=1;
ybase=1;
zbase=1;
}
void GetTheCoordinates(int posCoordinates coor)
{
Init();
if(pos==1)
{
return;
}
int semi=0;
int cycle=0;
while(true)
{
if(pos>=start&&pos<=end)
{
break;
}
start=end+1;
laps++;
end=start+laps*6-1;
xbase+=xjump;
ybase+=yjump;
zbase+=zjump;
xjump+=leap;
zjump+=leap;
yjump+=leap;
cycle=leap*laps;
}
int coorx=CalCoor(pos cycle xbase);
coor.setX(coorx);
int coory=CalCoor(pos cycle ybase);
coor.setY(coory);
int coorz=CalCoor(pos cycle zbase);
coor.setZ(coorz);
}
int CalCoor(int posint cycleint base)
{
int temp=pos-base;
int semi=cycle/2;
if(temp<0)
{
temp=cycle-temp;
}
int cor=temp%semi;
if(cor>laps)
{
cor=semi-cor;
if(cor>laps)
{
cor=laps;
}
}
if(temp {
cor=0-cor;
}
return cor;
}
int GetRouts(int xint yint z)
{
x=Math.abs(x);
y=Math.abs(y);
z=Math.abs(z);
int dis=x>y?x:y;
dis=dis>z?dis:z;
return dis;
}
class Coordinates
{
private int x;
private int y;
private int z;
Coordinates()
{
x=0;
y=0;
z=0;
}
public int getX() {
return x;
}
public void setX(int x) {
this.x = x;
}
public int getY() {
return y;
}
public void setY(int y) {
this.y = y;
}
public int getZ() {
return z;
}
public void setZ(int z) {
this.z = z;
}
}
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2014-06-05 15:41 src\
目录 0 2014-08-02 23:05 src\main\
文件 2239 2014-08-02 23:38 src\main\CalRoutes.java
文件 370 2014-08-02 23:39 src\main\main.java
- 上一篇:electronic letters模板
- 下一篇:s3c44b0x的公版电路原理图
相关资源
- CoreUIVue是基于Bootstrap4的免费Vue管理模
- SpringBoot+H2+mybatis-plus59130
- 登录注册界面.zip48872
- 数字华容道
- SSM+Shiro+redis实现单点登陆
- jstl-api-1.2和jstl-impl-1.2
- 基于MVC模式的会员管理系统
- 国内一家大型软件公司内部的正规软
- 仿windows记事本
- GUI银行管理系统
- 超市收银系统eclipse access大学课程设计
- 模拟ATM柜员机系统--连接数据库
- A*算法的2D演示(带源码)
- 路由选择算法源程序(最短路径算法
- 代码审查表和代码审查实例
- 仿126 网易 163 邮箱 界面
- Tomcat6.x
- 简单的行编辑器
- 扫雷(MVC架构)
- 302 Found
- window ping命令加时间并记录日志
- springboot+rabbitmq项目demo(亲测可正常运
- jxbrowser 所有版本通用的破解包
- 2017年-传智播客-张志君老师-SpringBoo
- Blob.js+Export2Excel.js
- 机会路由源代码+仿真工具(SCORP)
- POI中文帮助文档附带api手册.zip
- 2018双十一阿里供应链服务平台讲座
- 原银在线信贷平台概要设计说明书v
- office_word_api 开发文档
评论
共有 条评论