算法
shuishou119800
程序
展开
-
内螺旋矩阵算法分析
算法说明: 在屏幕上打印如下结果: int i=5; 1 2 3 4 5 16 17 18 19 6 15 24 25 20 7 14 23 22 21 8 13 12 11 10 9 int i=6 1 2 3 4 5 6 20 21 ...2009-12-16 12:39:06 · 673 阅读 · 0 评论 -
带条件的排列组合算法分析
算法说明: 用1、2、2、3、4、5这六个数字打印出所有不同的排列,如:512234、412345等。要求:"4"不能在第三位,"3"与"5"不能相连 算法代码: public class PermutationAlgo { private int count = 0; public void calculate(){ String eleStr = "...2009-12-16 13:07:27 · 620 阅读 · 0 评论 -
用桥梁模式实现螺旋矩阵算法
前两天写了一篇文章,分析了“内螺旋矩阵算法”的实现,讨论到了面向对象编程的可扩展性,于是今天用桥梁模式将代码做了些改造,具体如下: package com.algo; class Position { private int x; private int y; public Position(int x, int y) { this.x = x; this.y ...2009-12-17 21:01:06 · 116 阅读 · 0 评论