網頁

2013年12月9日 星期一

河內塔java程式



35 則留言:

  1. B10133048 饒家華2013年12月10日上午8:23

    public class HanoiTower {
    static int count=0;
    static void h(int d, int peg1, int peg2, int peg3){
    if (d==1)
    System.out.println((++count)+"次:盤子"+"◎"+"從"+peg1+"move"+"→"+peg3);
    else{
    h(d-1,peg1,peg3,peg2);
    System.out.println((++count)+"次:盤子"+"◎"+"從"+peg1+"move"+"→"+peg3);
    h(d-1,peg2,peg1,peg3);
    }
    }
    public static void main(String[] args) {
    int d=3;
    h(d,1,2,3);

    }

    }

    回覆刪除
  2. B10133048 饒家華2013年12月10日上午8:34

    public class HanoiTower {
    static int count=0;
    static void h(int d, int peg1, int peg2, int peg3){
    if (d==1)
    System.out.println((++count)+"次:盤子"+"◎"+d+"從"+peg1+"move"+"→"+peg3);

    else{
    h(d-1,peg1,peg3,peg2);
    System.out.println((++count)+"次:盤子"+"◎"+d+"從"+peg1+"move"+"→"+peg3);
    h(d-1,peg2,peg1,peg3);
    }
    }
    public static void main(String[] args) {
    int d=3;
    h(d,1,2,3);

    }

    }

    回覆刪除
  3. B9933137 黃宇儂2013年12月10日下午2:05

    public class HanoiTower {
    static int count=0;
    static void h(int d, int peg1, int peg2, int peg3){
    if (d==1)
    System.out.println((++count)+"次:盤子"+"◎"+d+"從"+peg1+"move"+"→"+peg3);

    else{
    h(d-1,peg1,peg3,peg2);
    System.out.println((++count)+"次:盤子"+"◎"+d+"從"+peg1+"move"+"→"+peg3);
    h(d-1,peg2,peg1,peg3);
    }
    }
    public static void main(String[] args) {
    int d=3;
    h(d,1,2,3);

    }

    }

    回覆刪除
  4. B10133002 謝佩紋2013年12月15日凌晨12:28

    public class HanoiTower {
    static int count=0;
    static void h(int d, int peg1, int peg2, int peg3){
    if (d==1)
    System.out.println((++count)+"次:盤子"+"◎"+"從"+peg1+"move"+"→"+peg3);
    else{
    h(d-1,peg1,peg3,peg2);
    System.out.println((++count)+"次:盤子"+"◎"+"從"+peg1+"move"+"→"+peg3);
    h(d-1,peg2,peg1,peg3);
    }
    }
    public static void main(String[] args) {
    int d=3;
    h(d,1,2,3);

    }

    }

    回覆刪除
  5. B10133025 王柏文
    public class HanoiTower {
    static int count=0;
    static void h(int d, int peg1, int peg2, int peg3){
    if (d==1)
    System.out.println((++count)+"次:盤子"+"◎"+"從"+peg1+"move"+"→"+peg3);
    else{
    h(d-1,peg1,peg3,peg2);
    System.out.println((++count)+"次:盤子"+"◎"+"從"+peg1+"move"+"→"+peg3);
    h(d-1,peg2,peg1,peg3);
    }
    }
    public static void main(String[] args) {
    int d=3;
    h(d,1,2,3);

    }

    }

    回覆刪除
  6. public class HanoiTower {
    static int count=0;
    static void h(int d, int peg1, int peg2, int peg3){
    if (d==1)
    System.out.println((++count)+"次:盤子"+"◎"+d+"從"+peg1+"move"+"→"+peg3);

    else{
    h(d-1,peg1,peg3,peg2);
    System.out.println((++count)+"次:盤子"+"◎"+d+"從"+peg1+"move"+"→"+peg3);
    h(d-1,peg2,peg1,peg3);
    }
    }
    public static void main(String[] args) {
    int d=3;
    h(d,1,2,3);

    }

    }

    回覆刪除
  7. public class HanoiTower {
    static int count=0;
    static void h(int d, int peg1, int peg2, int peg3){
    if (d==1)
    System.out.println((++count)+"次:盤子"+"◎"+"從"+peg1+"move"+"→"+peg3);
    else{
    h(d-1,peg1,peg3,peg2);
    System.out.println((++count)+"次:盤子"+"◎"+"從"+peg1+"move"+"→"+peg3);
    h(d-1,peg2,peg1,peg3);
    }
    }
    public static void main(String[] args) {
    int d=3;
    h(d,1,2,3);

    }

    }

    回覆刪除
  8. public class sam {
    static int count=0;
    static void h(int d, int peg1, int peg2, int peg3){
    if (d==1)
    System.out.println((++count)+"次:盤子"+"◎"+"從"+peg1+"move"+"→"+peg3);
    else{
    h(d-1,peg1,peg3,peg2);
    System.out.println((++count)+"次:盤子"+"◎"+"從"+peg1+"move"+"→"+peg3);
    h(d-1,peg2,peg1,peg3);
    }
    }
    public static void main(String[] args) {
    int d=3;
    h(d,1,2,3);

    }

    }

    回覆刪除
  9. b10033185邱詩婕2013年12月16日下午2:12

    public class ds {
    static int count=0;
    static void h(int d, int peg1, int peg2, int peg3){
    if (d==1)
    System.out.println((++count)+"次:盤子"+"◎"+"從"+peg1+"move"+"→"+peg3);
    else{
    h(d-1,peg1,peg3,peg2);
    System.out.println((++count)+"次:盤子"+"◎"+"從"+peg1+"move"+"→"+peg3);
    h(d-1,peg2,peg1,peg3);
    }
    }
    public static void main(String[] args) {
    int d=3;
    h(d,1,2,3);

    }

    }

    回覆刪除
  10. b10133016王致翔2013年12月16日下午2:12

    public class adsl {
    static int count=0;
    static void h(int d, int peg1, int peg2, int peg3){
    if (d==1)
    System.out.println((++count)+"次:盤子"+"◎"+"從"+peg1+"move"+"→"+peg3);
    else{
    h(d-1,peg1,peg3,peg2);
    System.out.println((++count)+"次:盤子"+"◎"+"從"+peg1+"move"+"→"+peg3);
    h(d-1,peg2,peg1,peg3);
    }
    }
    public static void main(String[] args) {
    int d=3;
    h(d,1,2,3);

    }

    }

    回覆刪除
  11. B10133046邱誌寬2013年12月16日下午2:13

    public class sup {
    static int count=0;
    static void h(int d, int peg1, int peg2, int peg3){
    if (d==1)
    System.out.println((++count)+"次:盤子"+"◎"+"從"+peg1+"move"+"→"+peg3);
    else{
    h(d-1,peg1,peg3,peg2);
    System.out.println((++count)+"次:盤子"+"◎"+"從"+peg1+"move"+"→"+peg3);
    h(d-1,peg2,peg1,peg3);
    }
    }
    public static void main(String[] args) {
    int d=3;
    h(d,1,2,3);

    }

    }

    回覆刪除
  12. B10133045林玹安2013年12月16日下午2:13

    public class AD {
    static int count=0;
    static void h(int d, int peg1, int peg2, int peg3){
    if (d==1)
    System.out.println((++count)+"次:盤子"+"◎"+"從"+peg1+"move"+"→"+peg3);
    else{
    h(d-1,peg1,peg3,peg2);
    System.out.println((++count)+"次:盤子"+"◎"+"從"+peg1+"move"+"→"+peg3);
    h(d-1,peg2,peg1,peg3);
    }
    }
    public static void main(String[] args) {
    int d=3;
    h(d,1,2,3);

    }

    }

    回覆刪除
  13. B10133044吳盛盟2013年12月16日晚上7:26

    public class jpm {
    static int count=0;
    static void h(int d, int peg1, int peg2, int peg3){
    if (d==1)
    System.out.println((++count)+"次:盤子"+"◎"+"從"+peg1+"move"+"→"+peg3);
    else{
    h(d-1,peg1,peg3,peg2);
    System.out.println((++count)+"次:盤子"+"◎"+"從"+peg1+"move"+"→"+peg3);
    h(d-1,peg2,peg1,peg3);
    }
    }
    public static void main(String[] args) {
    int d=3;
    h(d,1,2,3);

    }

    }

    回覆刪除
  14. B10133051張丞緯2013年12月16日晚上8:26

    public class AK {
    static int count=0;
    static void h(int d, int peg1, int peg2, int peg3){
    if (d==1)
    System.out.println((++count)+"次:盤子"+"◎"+"從"+peg1+"move"+"→"+peg3);
    else{
    h(d-1,peg1,peg3,peg2);
    System.out.println((++count)+"次:盤子"+"◎"+"從"+peg1+"move"+"→"+peg3);
    h(d-1,peg2,peg1,peg3);
    }
    }
    public static void main(String[] args) {
    int d=3;
    h(d,1,2,3);

    }

    }

    回覆刪除
  15. B10133018翁湘姿2013年12月16日晚上8:30

    public class HanoiTower {
    static int count=0;
    static void h(int d, int peg1, int peg2, int peg3){
    if (d==1)
    System.out.println((++count)+"次:盤子"+"◎"+d+"從"+peg1+"move"+"→"+peg3);

    else{
    h(d-1,peg1,peg3,peg2);
    System.out.println((++count)+"次:盤子"+"◎"+d+"從"+peg1+"move"+"→"+peg3);
    h(d-1,peg2,peg1,peg3);
    }
    }
    public static void main(String[] args) {
    int d=3;
    h(d,1,2,3);

    }

    }

    回覆刪除
  16. B10133030林潔如2013年12月16日晚上8:31

    public class HanoiTower {
    static int count=0;
    static void h(int d, int peg1, int peg2, int peg3){
    if (d==1)
    System.out.println((++count)+"次:盤子"+"◎"+d+"從"+peg1+"move"+"→"+peg3);

    else{
    h(d-1,peg1,peg3,peg2);
    System.out.println((++count)+"次:盤子"+"◎"+d+"從"+peg1+"move"+"→"+peg3);
    h(d-1,peg2,peg1,peg3);
    }
    }
    public static void main(String[] args) {
    int d=3;
    h(d,1,2,3);

    }

    }

    回覆刪除
  17. B10133031邱敏惠2013年12月16日晚上8:37

    public class HanoiTower {
    static int count=0;
    static void h(int d, int peg1, int peg2, int peg3){
    if (d==1)
    System.out.println((++count)+"次:盤子"+"◎"+d+"從"+peg1+"move"+"→"+peg3);

    else{
    h(d-1,peg1,peg3,peg2);
    System.out.println((++count)+"次:盤子"+"◎"+d+"從"+peg1+"move"+"→"+peg3);
    h(d-1,peg2,peg1,peg3);
    }
    }
    public static void main(String[] args) {
    int d=3;
    h(d,1,2,3);

    }

    }

    回覆刪除
  18. B10133047鄭兆珊2013年12月16日晚上8:37

    public class HanoiTower {
    static int count=0;
    static void h(int d, int peg1, int peg2, int peg3){
    if (d==1)
    System.out.println((++count)+"次:盤子"+"◎"+d+"從"+peg1+"move"+"→"+peg3);

    else{
    h(d-1,peg1,peg3,peg2);
    System.out.println((++count)+"次:盤子"+"◎"+d+"從"+peg1+"move"+"→"+peg3);
    h(d-1,peg2,peg1,peg3);
    }
    }
    public static void main(String[] args) {
    int d=3;
    h(d,1,2,3);

    }

    }

    回覆刪除
  19. B10133042沈俞宜2013年12月16日晚上8:42

    public class ket {
    static int count=0;
    static void h(int d, int peg1, int peg2, int peg3){
    if (d==1)
    System.out.println((++count)+"次:盤子"+"◎"+d+"從"+peg1+"move"+"→"+peg3);

    else{
    h(d-1,peg1,peg3,peg2);
    System.out.println((++count)+"次:盤子"+"◎"+d+"從"+peg1+"move"+"→"+peg3);
    h(d-1,peg2,peg1,peg3);
    }
    }
    public static void main(String[] args) {
    int d=3;
    h(d,1,2,3);

    }

    }

    回覆刪除
  20. B10133033呂之筠2013年12月16日晚上8:42

    public class wen {
    static int count=0;
    static void h(int d, int peg1, int peg2, int peg3){
    if (d==1)
    System.out.println((++count)+"次:盤子"+"◎"+d+"從"+peg1+"move"+"→"+peg3);

    else{
    h(d-1,peg1,peg3,peg2);
    System.out.println((++count)+"次:盤子"+"◎"+d+"從"+peg1+"move"+"→"+peg3);
    h(d-1,peg2,peg1,peg3);
    }
    }
    public static void main(String[] args) {
    int d=3;
    h(d,1,2,3);

    }

    }

    回覆刪除
  21. public class sup {
    static int count=0;
    static void h(int d, int peg1, int peg2, int peg3){
    if (d==1)
    System.out.println((++count)+"次:盤子"+"◎"+"從"+peg1+"move"+"→"+peg3);
    else{
    h(d-1,peg1,peg3,peg2);
    System.out.println((++count)+"次:盤子"+"◎"+"從"+peg1+"move"+"→"+peg3);
    h(d-1,peg2,peg1,peg3);
    }
    }
    public static void main(String[] args) {
    int d=3;
    h(d,1,2,3);

    }

    }

    回覆刪除
  22. public class HanoiTower {
    static int count=0;
    static void h(int d, int peg1, int peg2, int peg3){
    if (d==1)
    System.out.println((++count)+"次:盤子"+"◎"+d+"從"+peg1+"move"+"→"+peg3);

    else{
    h(d-1,peg1,peg3,peg2);
    System.out.println((++count)+"次:盤子"+"◎"+d+"從"+peg1+"move"+"→"+peg3);
    h(d-1,peg2,peg1,peg3);
    }
    }
    public static void main(String[] args) {
    int d=3;
    h(d,1,2,3);

    }

    }

    回覆刪除
  23. public class HanoiTower {
    static int count=0;
    static void h(int d, int peg1, int peg2, int peg3){
    if (d==1)
    System.out.println((++count)+"次:盤子"+"◎"+d+"從"+peg1+"move"+"→"+peg3);

    else{
    h(d-1,peg1,peg3,peg2);
    System.out.println((++count)+"次:盤子"+"◎"+d+"從"+peg1+"move"+"→"+peg3);
    h(d-1,peg2,peg1,peg3);
    }
    }
    public static void main(String[] args) {
    int d=3;
    h(d,1,2,3);

    }

    }

    回覆刪除
  24. B10133011 黃怡蓁2013年12月20日中午12:48

    public class HanoiTower {
    static int count=0;
    static void h(int d, int peg1, int peg2, int peg3){
    if (d==1)
    System.out.println((++count)+"次:盤子"+"◎"+"從"+peg1+"move"+"→"+peg3);
    else{
    h(d-1,peg1,peg3,peg2);
    System.out.println((++count)+"次:盤子"+"◎"+"從"+peg1+"move"+"→"+peg3);
    h(d-1,peg2,peg1,peg3);
    }
    }
    public static void main(String[] args) {
    int d=3;
    h(d,1,2,3);

    }

    }

    回覆刪除
  25. B10133014 吳欣怡2013年12月20日中午12:48

    public class HanoiTower {
    static int count=0;
    static void h(int d, int peg1, int peg2, int peg3){
    if (d==1)
    System.out.println((++count)+"次:盤子"+"◎"+"從"+peg1+"move"+"→"+peg3);
    else{
    h(d-1,peg1,peg3,peg2);
    System.out.println((++count)+"次:盤子"+"◎"+"從"+peg1+"move"+"→"+peg3);
    h(d-1,peg2,peg1,peg3);
    }
    }
    public static void main(String[] args) {
    int d=3;
    h(d,1,2,3);

    }

    }

    回覆刪除
  26. B10133007 蔡雅姿2013年12月20日中午12:49

    public class HanoiTower {
    static int count=0;
    static void h(int d, int peg1, int peg2, int peg3){
    if (d==1)
    System.out.println((++count)+"次:盤子"+"◎"+"從"+peg1+"move"+"→"+peg3);
    else{
    h(d-1,peg1,peg3,peg2);
    System.out.println((++count)+"次:盤子"+"◎"+"從"+peg1+"move"+"→"+peg3);
    h(d-1,peg2,peg1,peg3);
    }
    }
    public static void main(String[] args) {
    int d=3;
    h(d,1,2,3);

    }

    }

    回覆刪除
  27. public class HanoiTower {
    static int count=0;
    static void h(int d, int peg1, int peg2, int peg3){
    if (d==1)
    System.out.println((++count)+"次:盤子"+"◎"+"從"+peg1+"move"+"→"+peg3);
    else{
    h(d-1,peg1,peg3,peg2);
    System.out.println((++count)+"次:盤子"+"◎"+"從"+peg1+"move"+"→"+peg3);
    h(d-1,peg2,peg1,peg3);
    }
    }
    public static void main(String[] args) {
    int d=3;
    h(d,1,2,3);

    }

    }

    回覆刪除
  28. B10133049 連于瑄2013年12月20日中午12:51

    public class HanoiTower {
    static int count=0;
    static void h(int d, int peg1, int peg2, int peg3){
    if (d==1)
    System.out.println((++count)+"次:盤子"+"◎"+"從"+peg1+"move"+"→"+peg3);
    else{
    h(d-1,peg1,peg3,peg2);
    System.out.println((++count)+"次:盤子"+"◎"+"從"+peg1+"move"+"→"+peg3);
    h(d-1,peg2,peg1,peg3);
    }
    }
    public static void main(String[] args) {
    int d=3;
    h(d,1,2,3);

    }

    }

    回覆刪除
  29. B10133004徐芷瑩2013年12月20日下午1:10

    public class HanoiTower {
    static int count=0;
    static void h(int d, int peg1, int peg2, int peg3){
    if (d==1)
    System.out.println((++count)+"次:盤子"+"◎"+"從"+peg1+"move"+"→"+peg3);
    else{
    h(d-1,peg1,peg3,peg2);
    System.out.println((++count)+"次:盤子"+"◎"+"從"+peg1+"move"+"→"+peg3);
    h(d-1,peg2,peg1,peg3);
    }
    }
    public static void main(String[] args) {
    int d=3;
    h(d,1,2,3);

    }

    }

    回覆刪除
  30. B10133010蔡以翎2013年12月20日下午1:10

    public class HanoiTower {
    static int count=0;
    static void h(int d, int peg1, int peg2, int peg3){
    if (d==1)
    System.out.println((++count)+"次:盤子"+"◎"+"從"+peg1+"move"+"→"+peg3);
    else{
    h(d-1,peg1,peg3,peg2);
    System.out.println((++count)+"次:盤子"+"◎"+"從"+peg1+"move"+"→"+peg3);
    h(d-1,peg2,peg1,peg3);
    }
    }
    public static void main(String[] args) {
    int d=3;
    h(d,1,2,3);

    }

    }

    回覆刪除
  31. B10133053古聿穎2013年12月25日晚上7:42

    public class HanoiTower {
    static int count=0;
    static void h(int d, int peg1, int peg2, int peg3){
    if (d==1)
    System.out.println((++count)+"次:盤子"+"◎"+d+"從"+peg1+"move"+"→"+peg3);

    else{
    h(d-1,peg1,peg3,peg2);
    System.out.println((++count)+"次:盤子"+"◎"+d+"從"+peg1+"move"+"→"+peg3);
    h(d-1,peg2,peg1,peg3);
    }
    }
    public static void main(String[] args) {
    int d=3;
    h(d,1,2,3);

    }

    }

    回覆刪除
  32. b10133021吳屹軒2013年12月26日下午5:06

    public class HanoiTower {
    static int count=0;
    static void h(int d, int peg1, int peg2, int peg3){
    if (d==1)
    System.out.println((++count)+"次:盤子"+"◎"+"從"+peg1+"move"+"→"+peg3);
    else{
    h(d-1,peg1,peg3,peg2);
    System.out.println((++count)+"次:盤子"+"◎"+"從"+peg1+"move"+"→"+peg3);
    h(d-1,peg2,peg1,peg3);
    }
    }
    public static void main(String[] args) {
    int d=3;
    h(d,1,2,3);

    }

    }

    回覆刪除
  33. b10133021吳屹軒2013年12月26日下午5:07

    public class HanoiTower {
    static int count=0;
    static void h(int d, int peg1, int peg2, int peg3){
    if (d==1)
    System.out.println((++count)+"次:盤子"+"◎"+"從"+peg1+"move"+"→"+peg3);
    else{
    h(d-1,peg1,peg3,peg2);
    System.out.println((++count)+"次:盤子"+"◎"+"從"+peg1+"move"+"→"+peg3);
    h(d-1,peg2,peg1,peg3);
    }
    }
    public static void main(String[] args) {
    int d=3;
    h(d,1,2,3);

    }

    }

    回覆刪除
  34. B10133020 李涵清2013年12月29日晚上9:06

    public class HanoiTower {
    static int count=0;
    static void h(int d, int peg1, int peg2, int peg3){
    if (d==1)
    System.out.println((++count)+"次:盤子"+"◎"+"從"+peg1+"move"+"→"+peg3);
    else{
    h(d-1,peg1,peg3,peg2);
    System.out.println((++count)+"次:盤子"+"◎"+"從"+peg1+"move"+"→"+peg3);
    h(d-1,peg2,peg1,peg3);
    }
    }
    public static void main(String[] args) {
    int d=3;
    h(d,1,2,3);

    }

    }

    回覆刪除
  35. public class HanoiTower {
    static int count=0;
    static void h(int d, int peg1, int peg2, int peg3){
    if (d==1)
    System.out.println((++count)+"次:盤子"+"◎"+"從"+peg1+"move"+"→"+peg3);
    else{
    h(d-1,peg1,peg3,peg2);
    System.out.println((++count)+"次:盤子"+"◎"+"從"+peg1+"move"+"→"+peg3);
    h(d-1,peg2,peg1,peg3);
    }
    }
    public static void main(String[] args) {
    int d=3;
    h(d,1,2,3);

    }

    }

    回覆刪除

HTML 編輯器