亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? knightstour.java~61~

?? Java課程設計案例精編光盤源碼
?? JAVA~61~
字號:
package gao;import java.awt.*;import java.awt.event.*;import javax.swing.*;import java.awt.image.*;public class KnightsTour extends JApplet {   public static int access[][] = {      {2,3,4,4,4,4,3,2},      {3,4,6,6,6,6,4,3},      {4,6,8,8,8,8,6,4},      {4,6,8,8,8,8,6,4},      {4,6,8,8,8,8,6,4},      {4,6,8,8,8,8,6,4},      {3,4,6,6,6,6,4,3},      {2,3,4,4,4,4,3,2}};   public static int accessbak[][] = arrayCopy ( access ) ;   // the value indicate the No.value moving   int countMoving = -1 ;   int tourXpos [] = new int [ 64 ];   int tourYpos [] = new int [ 64 ];   private int recordXpos [][];   private int recordYpos [][];   private int recordCount = - 1 ;   private boolean success = false;   MyPanel myPanel ;   public void tour ( int xpos ,int ypos ){//      int x,y;      countMoving ++ ;      //all the  64 squares has been touch , return      if (countMoving == 63 )      {         tourXpos [ countMoving ] = xpos ;         tourYpos [ countMoving ] = ypos ;         success = true ;         countMoving -- ;         return ;      }      AccessibleSquares nextSquare = new AccessibleSquares( xpos, ypos );      while (nextSquare.hasMoreAccessible())      {         // do moving         nextSquare.domoving();         //record this moving         tourXpos [ countMoving ] = xpos ;         tourYpos [ countMoving ] = ypos ;         // try the next moving         nextSquare.nextAccessible();         tour ( nextSquare.getXpos() , nextSquare.getYpos() );         //all the  64 squares has been touch , return         if ( success )         {            countMoving -- ;            return ;         }         //this moving try is a faillure, pick it up from the chess board         nextSquare.undomoving();      }// end of while      countMoving -- ;   }//end of tour method   public static int[] arrayCopy ( int array1[] )   {     int[]array2 = new int [array1.length];     for ( int row = 0 ; row < array1.length ; row ++ )     {          array2 [ row ] = array1  [ row ] ;     };     return array2;   }   public static int[][] arrayCopy ( int array1[][]  )   {      int[][] array2 = new int [array1.length][array1[0].length];     for ( int row = 0 ; row < array1.length ; row ++ )     {        for ( int column = 0 ; column < array1[0].length ; column ++ )        {          array2 [ row ][ column ] = array1  [ row ][ column ];        };     };     return array2;   }   public void initialArray ( int chessBoard[][]  )   {     for ( int row = 0 ; row < 8 ; row ++ )     {        for ( int column = 0 ; column < 8 ; column ++ )        {          chessBoard [ row ][ column ] = 0 ;        };     };   }/*   public static void main( String args[] ) {      KnightsTour application = new KnightsTour();      application.tour( 0 , 0 );   }*/   public void init () {      recordCount = -1 ;      recordXpos = new int [ 64 ][ 64 ] ;      recordYpos = new int [ 64 ][ 64 ] ;      for (int row = 0 ; row < 8 ;row ++){         for ( int column = 0 ; column < 8 ; column ++ ){            success = false ;            countMoving = -1;            access = arrayCopy ( accessbak );            tour ( row ,column );            recordCount ++ ;            recordXpos [ recordCount ] = arrayCopy ( tourXpos ) ;            recordYpos [ recordCount ] = arrayCopy ( tourYpos ) ;         }      }      recordCount = -1 ;      myPanel = new MyPanel( recordXpos [ 0 ] ,recordYpos [ 0 ]) ;      JPanel buttonPanel = new JPanel();      JButton nextMoving = new JButton( "Next Moving" );      JButton nextTour = new JButton( "Next Tour" );      buttonPanel.add( nextTour );      buttonPanel.add( nextMoving );      getContentPane().add( buttonPanel, BorderLayout.SOUTH );      getContentPane().add( myPanel );      nextMoving.addActionListener(         //anonymous inner class         new ActionListener() {            public void actionPerformed ( ActionEvent e ) {               myPanel.showNext() ;            }         }         );//end call to addActionListener         nextTour.addActionListener(            //anonymous inner class            new ActionListener() {               public void actionPerformed ( ActionEvent e ) {                  if ( recordCount < recordXpos.length - 1 ) {                     recordCount ++ ;                  } else {                     recordCount = 0 ;                  }                  myPanel.initboard ( recordXpos [ recordCount ] , recordYpos [ recordCount ] );               }            }            );//end call to addActionListener   }   public void paint (Graphics g )   {      super.paint( g );/*      success = false ;      countMoving = -1;      access = arrayCopy ( accessbak );      tour ( 7 , 6 );      for ( int row = 0 ; row < 9 ; row ++ )      {         g.drawLine( 10 , 10 + 32 * row , 32 * 8 + 10 , 10 + 32 * row  );      }      for ( int column = 0 ; column < 9 ; column ++ )      {         g.drawLine( 10 + 32 * column , 10  , 10 + 32 * column , 32 * 8 + 10 );      };      for ( int count = 0 ; count < tourXpos.length ; count ++ )      {         g.drawString("" + count , 26 + 32 * tourXpos[ count ] ,32 + 32 * tourYpos [ count ] );      };*/   }}//end of class KnightsTourclass AccessibleSquares {   private static int horizontal[] = {2,1,-1,-2,-2,-1,1,2};   private static int vertical  [] = {-1,-2,-2,-1,1,2,2,1};   private int xpos[] ;   private int ypos[] ;   private int accessibility [];   private int ownxpos ,ownypos ;   private int ownAccessibility ;   private int arrayPos ;   private int countAccessibility;   public AccessibleSquares(int x , int y ){      int testXPos;      int testYPos;      xpos = new int [ 8 ];      ypos = new int [ 8 ];      accessibility = new int [ 8 ];      arrayPos = 0 ;      ownxpos = x ;      ownypos = y ;      ownAccessibility = KnightsTour.access[ x ][ y ];      for (int i = 0 ; i < horizontal.length ; i++ ){         testXPos = x + horizontal[ i ];         testYPos = y + vertical  [ i ];         if ( (testXPos >= 0 ) & ( testXPos < 8 ) &              (testYPos >= 0 ) & ( testYPos < 8 ) ) {            xpos [ arrayPos ] = testXPos ;            ypos [ arrayPos ] = testYPos ;            accessibility [ arrayPos ] = KnightsTour.access [testXPos][testYPos];            //because  accessibility [ arrayPos ] = 0 indicating the square has been occupied            if (accessibility [ arrayPos ] > 0 )               arrayPos ++ ;         }//end of if      }// end of for      countAccessibility = arrayPos ;      if (countAccessibility > 0 )         {sortAll();}      arrayPos = -1 ;   }// end of constructor   public boolean hasMoreAccessible(){      // arrayPos + 1 point to the next accessible      if ( (arrayPos + 1 ) < countAccessibility ){         return true;      }else {         return false;      }   }//end of the hasMoreAccessible()   public AccessibleSquares nextAccessible(){      arrayPos ++ ;      return this;   }   public AccessibleSquares accessibleAt( int pos){      if ((pos >= 0) & (pos < countAccessibility ))      arrayPos = pos ;      return this;   }   public int getXpos(){      return xpos[ arrayPos ];   }   public int getYpos(){      return ypos[ arrayPos ];   }   public int getAccessibility(){      return accessibility[ arrayPos ];   }   public int getTotalAccessible(){      return countAccessibility;   }   //bubble sorting   private void sortAll (){      for ( int begin = 0 ; begin < countAccessibility - 1 ; begin ++ ){         for ( int i = begin + 1; i < countAccessibility ; i ++ ){            if ( accessibility [ begin ] > accessibility [ i ] ){               swapAll( begin, i );            }//end of if         }// end of inner for      }// end of outer for   }// end of sortAll   private void swapAll ( int i , int j ){      int temp ;      temp = xpos [ i ];      xpos [ i ] = xpos [ j ];      xpos [ j ] = temp;      temp = ypos [ i ];      ypos [ i ] = ypos [ j ];      ypos [ j ] = temp;      temp = accessibility [ i ];      accessibility [ i ] = accessibility [ j ];      accessibility [ j ] = temp;   }   public void domoving(){      for ( int i = 0 ; i < countAccessibility ; i ++ ){         KnightsTour.access[ xpos [i] ][ ypos[i] ] -- ;      }       KnightsTour.access[ ownxpos ][ ownypos ] = 0 ;   }   public void undomoving(){      for ( int i = 0 ; i < countAccessibility ; i ++ ){         KnightsTour.access[ xpos [i] ][ ypos[i] ] ++ ;      }      KnightsTour.access[ ownxpos ][ ownypos ] = ownAccessibility ;   }}class MyPanel extends JPanel {   public static final int WHITE = 0 ;   public static final int BLACK = 1 ;   public static final int WKNIGHT = 2 ;   public static final int BKNIGHT = 3 ;   private int chessboard[][];   private int xrecord [] ;   private int yrecord [] ;   private int displayCount ;   private int lastxpos ,lastypos ,nextxpos ,nextypos ;   ImageIcon images[] ;   private boolean start ;   public MyPanel() {      initvariance();   }   public MyPanel( int [] newxrecord ,int [] newyrecord ) {      initvariance();      initboard( newxrecord , newyrecord );   }   public void initvariance () {      chessboard = new int[ 8 ][ 8 ];      xrecord = new int [ 64 ] ;      yrecord = new int [ 64 ];      images = new ImageIcon [ 4 ];      images[ 0 ] = new ImageIcon( "white.jpg");      images[ 1 ] = new ImageIcon( "black.jpg");      images[ 2 ] = new ImageIcon( "wknight.jpg");      images[ 3 ] = new ImageIcon( "bknight.jpg");   }   public void initboard ( int [] newxrecord ,int [] newyrecord ){      start = true ;      displayCount = -1 ;      for (int row = 0 ; row < 8 ;row ++){         for ( int column = 0 ; column < 8 ; column ++ ){            // white use 0 ,black use 1            chessboard [ row ][ column ] = ( row + column ) % 2 ;         }      }//end of outer for      for ( int row = 0 ; row < newxrecord .length ; row ++ ) {         xrecord [ row ] = newxrecord [ row ] ;         yrecord [ row ] = newyrecord [ row ] ;      }      displayCount = 0 ;      chessboard [ xrecord [ displayCount ] ][ yrecord [ displayCount ] ] += 2 ;   }//end of initboard   public void showNext() {      if ( displayCount < xrecord.length - 1 ){         displayCount ++ ;         chessboard [ xrecord [ displayCount ] ][ yrecord [ displayCount ] ] += 2 ;         repaint();      }   }   public void paintComponent ( Graphics g ) {      for (int row = 0 ; row < 8 ;row ++){         for ( int column = 0 ; column < 8 ; column ++ ){            images[ chessboard[ row ][ column ] ].paintIcon( this , g, 40 * row,40 * column );         }//end of inner for      }//end of outer for      if ( displayCount > 0 ){         lastxpos = xrecord [ displayCount  - 1];         lastypos = yrecord [ displayCount  - 1];         nextxpos = xrecord [ displayCount ];         nextypos = yrecord [ displayCount ];         g.setColor( Color.green);         g.drawRect( 40 * xrecord [ displayCount - 1 ] + 2,40 * yrecord [ displayCount - 1 ] + 2, 36, 36 );         g.setColor( Color.green);         g.drawRect( 40 * xrecord [ displayCount ] + 2 ,40 * yrecord [ displayCount ] + 2, 36, 36 );         g.setColor( Color.blue);         g.drawRect( 40 * Math.min( nextxpos, lastxpos ),            40 * Math.min( nextypos, lastypos ),            ( Math.abs( nextxpos - lastxpos ) + 1 ) * 40,            ( Math.abs( nextypos - lastypos ) + 1 ) * 40 );      }//end of if      g.setColor( Color.red );      g.drawRect ( xrecord [ 0 ] + 2, yrecord [ 0 ] + 2, 36, 36 ) ;   }// end of the method paintComponent}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国内一区二区在线| 国产一区二区91| 水野朝阳av一区二区三区| 久久久久久久久蜜桃| 日韩一区二区三区精品视频 | 首页综合国产亚洲丝袜| 亚洲电影一级片| 蜜乳av一区二区| 久久丁香综合五月国产三级网站| 久久亚洲免费视频| 国产ts人妖一区二区| 久久综合999| 91麻豆精品91久久久久同性| 色成人在线视频| 成人黄色电影在线| 成人小视频免费观看| 日韩二区三区在线观看| 国产丝袜欧美中文另类| 亚洲精品日产精品乱码不卡| 91免费观看视频| 国产精品白丝在线| 精品国产乱码91久久久久久网站| 成人黄色777网| 国产揄拍国内精品对白| 日本成人在线电影网| 伊人一区二区三区| 亚洲精品日韩一| 蜜桃在线一区二区三区| 一区二区三区精品在线| 国产精品综合av一区二区国产馆| 欧美成人高清电影在线| 欧美精品xxxxbbbb| 欧美精品免费视频| 亚洲国产精品二十页| 国产酒店精品激情| 日韩免费观看高清完整版在线观看| 亚洲人成伊人成综合网小说| 91小视频在线免费看| 中文在线免费一区三区高中清不卡| 韩国成人精品a∨在线观看| 宅男噜噜噜66一区二区66| 国产精品久久久久四虎| 国产精品传媒入口麻豆| 免费人成黄页网站在线一区二区| 国产成人综合网站| 欧美日韩精品欧美日韩精品一综合| 欧美日韩国产另类一区| 日韩一区在线播放| 国产自产高清不卡| 91在线国产福利| 国产麻豆视频精品| 欧美xxxxx牲另类人与| 久久福利资源站| 中文成人综合网| 一道本成人在线| 午夜成人在线视频| 精品毛片乱码1区2区3区| 国产精品国模大尺度视频| 不卡的电影网站| 99久久夜色精品国产网站| 亚洲精品高清视频在线观看| 欧美探花视频资源| 蜜桃av一区二区三区电影| 精品动漫一区二区三区在线观看| 久久成人麻豆午夜电影| 国产欧美日韩在线观看| 色一情一伦一子一伦一区| 亚洲aⅴ怡春院| 国产亚洲综合色| 欧美视频精品在线观看| 韩国av一区二区三区在线观看| 自拍偷拍亚洲综合| 日韩三级精品电影久久久| 成人免费视频一区| 日本vs亚洲vs韩国一区三区| 欧美激情一区二区三区| 欧美日本不卡视频| aa级大片欧美| 精品在线视频一区| 亚洲自拍偷拍欧美| 欧美国产一区视频在线观看| 欧美日韩三级一区| 国产不卡在线视频| 日本成人在线网站| 亚洲图片一区二区| 中文一区在线播放| 2024国产精品| 717成人午夜免费福利电影| 成人va在线观看| 国内精品久久久久影院薰衣草| 亚洲免费在线电影| 欧美高清在线一区| 日韩三级精品电影久久久| 色久综合一二码| 成人福利视频网站| 国产麻豆成人传媒免费观看| 午夜电影一区二区三区| 伊人婷婷欧美激情| 国产精品青草综合久久久久99| 一区二区三区在线高清| 中文字幕av一区二区三区免费看 | 日韩欧美成人一区二区| 91久久线看在观草草青青| 国产成人精品影视| 另类小说欧美激情| 免费观看91视频大全| 亚洲午夜精品在线| **欧美大码日韩| 国产精品天干天干在观线| 久久亚洲综合色| 精品日韩在线观看| 日韩三级免费观看| 日韩欧美综合一区| 日韩欧美精品三级| 欧美电视剧在线看免费| 欧美一级二级三级蜜桃| 欧美一区二区三区四区久久| 欧美一级在线免费| 欧美成人猛片aaaaaaa| 精品卡一卡二卡三卡四在线| 日韩精品一区二区三区老鸭窝| 欧美一区二区福利在线| 欧美大片国产精品| 久久婷婷国产综合精品青草| 国产日韩视频一区二区三区| 亚洲国产精品激情在线观看| 亚洲少妇屁股交4| 一区二区三区四区不卡在线| 亚洲一区二区三区四区在线| 性感美女极品91精品| 久久99久久99| 国产成人精品亚洲777人妖| av男人天堂一区| 成人午夜在线免费| 欧美不卡123| 中文字幕的久久| 亚洲成a人在线观看| 亚洲欧美日韩国产成人精品影院 | 精品毛片乱码1区2区3区| 91精品黄色片免费大全| 不卡的电影网站| 91九色02白丝porn| 欧洲精品在线观看| 欧美视频一区二区| 99精品视频一区| 91精品在线麻豆| 精品国产一区二区三区久久影院 | 在线欧美一区二区| 欧美精品自拍偷拍| 精品美女一区二区| 国产午夜精品久久久久久免费视 | 国产精品日日摸夜夜摸av| 国产精品免费视频一区| 自拍偷拍国产精品| 婷婷开心激情综合| 精品一区二区三区在线播放| 国产成人精品一区二区三区四区 | 国产成人啪免费观看软件| 成人激情免费视频| 欧美色精品在线视频| 精品国内二区三区| 精品国免费一区二区三区| 一区二区三区四区激情| 久久精品国产一区二区| 国产成人精品三级麻豆| 日本二三区不卡| 日韩亚洲欧美在线| 国产精品人人做人人爽人人添| 亚洲精选免费视频| 人妖欧美一区二区| 精品一区二区在线视频| 欧美日韩精品一区二区在线播放| 日韩一区二区三区视频| 国产精品成人免费在线| 日韩精品一级中文字幕精品视频免费观看| 国产传媒欧美日韩成人| 欧美无人高清视频在线观看| 久久在线观看免费| 亚洲国产欧美在线| 日韩二区三区四区| 欧美日韩一区二区三区免费看| 久久久久久久免费视频了| 亚洲图片欧美色图| www.在线欧美| 国产精品欧美一区喷水| 水蜜桃久久夜色精品一区的特点| 成人小视频在线| 日韩精品中午字幕| 麻豆成人免费电影| 欧美在线短视频| 国产精品久久久久影院| 麻豆精品一区二区av白丝在线| 欧美日韩国产a| 自拍av一区二区三区| 国产精品综合久久| 精品国产91乱码一区二区三区| 亚洲国产精品久久人人爱| www.久久精品| 亚洲美女免费视频| av一区二区三区四区|