JAVA最短路径代码
import java.util.LinkedList;
import java.util.List;
public class ShortestPaths {
private static String showPath[] = { "", "", "", "", "", "" };
// 返回图的最短路径
public static int[] getShortPath(int path[][]) {
LinkedList<Integer> savePath = new LinkedList<Integer>();// 用于保存已添加进来的节点
int mark = 1;
int shortestPath[] = new int[path.length];
for (int i = 0; i < shortestPath.length; i++) {
shortestPath[i] = -1;
}
savePath.add(new Integer(0));
if (savePath.size() == 1) {
int num = savePath.getLast().intValue();
int minIndex = 0;
for (int j = 0; j < shortestPath.length; j++) {
shortestPath[j] = path[num][j];
相关文档:
Java基础方面:
1、作用域public,private,protected,以及不写时的区别
答:区别如下:
作用域 当前类 同一package 子孙类 其他package
public& ......
作者: 佚名, 出处:IT专家网, 责任编辑: 谢妍妍, 2010-05-10 13:00
Java 把内存划分成两种:一种是栈内存,另一种是堆内存。在函数中定义的一些基本类型的变量和对象的引用变量都是在函数的栈内存中分配,当在一段代码块定义一个变量时,Java 就在栈中为这个变量分配内存空间,当超过变量的作用域后,Java 会自动释放掉 ......
移位运算符
包括:
“>> 右移”;“<< 左移”;“>>> 无符号右移”
例子:
-5>>3=-1
1111 1111 1111 1111 1111 1111 1111 1011
1111 1111 1111 1111 1111 1111 1111 1111
其结果与 Math.floor((double)- ......
(1). 创建一个接口, 要代理的类和 代理类都将继承它
package stone;
public interface Image {
public void show();
}
(2). 创建要被代理的类:
package stone;
public class BigImage implements Image {
public BigImage() {
......
import java.text.DateFormat;
import java.util.Calendar;
import java.util.Date;
/**
* @author troy(J2EE)
* @version 1.0
*/
public class Test {
public static void main(String[] args) throws Exception {
DateFormat df = DateFormat.getDateInstance();
&n ......