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

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

?? knightstour.java~64~

?? Java課程設計案例精編光盤源碼
?? JAVA~64~
字號:
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 = 0 ;      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 ] );                  myPanel.repaint();               }            }            );//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 ( 40 * xrecord [ 0 ] + 2,40 * yrecord [ 0 ] + 2, 36, 36 ) ;   }// end of the method paintComponent}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
麻豆91精品91久久久的内涵| 亚洲欧美日韩久久| 国产日韩欧美精品在线| 国产精品不卡视频| 夜夜嗨av一区二区三区网页 | 国产精品18久久久久久久久久久久 | 国产精品1024久久| 91在线视频网址| 欧美日韩国产高清一区二区三区 | 亚洲福利视频导航| 国产一区二区三区四| av中文一区二区三区| 欧美日韩综合在线免费观看| 日韩欧美国产午夜精品| 日韩久久一区二区| 美女视频网站黄色亚洲| 成人av电影观看| 在线91免费看| 国产精品国产三级国产aⅴ入口| 亚洲妇熟xx妇色黄| 国产伦精品一区二区三区免费| 91亚洲永久精品| 欧美大片在线观看| 亚洲精品国产一区二区精华液 | 日韩精品影音先锋| 曰韩精品一区二区| 国产露脸91国语对白| 欧美日韩一区高清| 国产精品视频免费看| 免费一级欧美片在线观看| 99精品国产99久久久久久白柏| 日韩一区二区在线播放| 亚洲视频在线一区观看| 激情文学综合网| 欧美日韩激情在线| 国产精品嫩草久久久久| 久久精品久久精品| 在线视频一区二区三| 日本一区二区三区视频视频| 日韩成人精品在线观看| 91捆绑美女网站| 国产午夜精品福利| 蜜臀av性久久久久蜜臀aⅴ流畅| 色综合色综合色综合 | 国产**成人网毛片九色 | 狠狠色丁香九九婷婷综合五月| 欧美色网一区二区| 亚洲欧美一区二区三区孕妇| 国产一区二区福利视频| 日韩欧美三级在线| 午夜精品久久久久久久蜜桃app | 欧美一区二区播放| 亚洲二区在线视频| 色欧美片视频在线观看| 中文字幕一区二区三区色视频| 国产一区 二区| 精品国产免费一区二区三区香蕉| 丝瓜av网站精品一区二区| 一道本成人在线| 亚洲人精品午夜| eeuss影院一区二区三区| 久久精品日产第一区二区三区高清版 | 国产宾馆实践打屁股91| 久久天天做天天爱综合色| 秋霞国产午夜精品免费视频| 欧美日韩三级一区| 夜夜夜精品看看| 色爱区综合激月婷婷| 一区二区三区在线影院| 一本大道久久a久久精二百| 中文字幕精品—区二区四季| 国产精品一二三四| 国产丝袜在线精品| 国产成人综合网| 欧美国产一区在线| 成人av片在线观看| 亚洲欧洲性图库| 色欧美日韩亚洲| 一区二区三区高清在线| 在线免费av一区| 午夜在线电影亚洲一区| 欧美精品三级在线观看| 日韩国产欧美在线播放| 欧美一区二区三区性视频| 麻豆精品精品国产自在97香蕉| 日韩欧美一区电影| 国产又粗又猛又爽又黄91精品| 久久亚洲精品小早川怜子| 国产成人午夜精品影院观看视频 | 成人动漫在线一区| 亚洲视频一区在线观看| 在线观看网站黄不卡| 日韩主播视频在线| 欧美α欧美αv大片| 国产乱码精品一品二品| 亚洲欧洲av另类| 欧美色图一区二区三区| 热久久国产精品| 国产色一区二区| 色天天综合久久久久综合片| 视频一区视频二区中文| 久久综合九色综合97婷婷女人 | 中文一区在线播放| 欧美在线色视频| 日av在线不卡| 国产精品国产三级国产普通话蜜臀| 91亚洲精品乱码久久久久久蜜桃| 一区二区三区产品免费精品久久75| 欧美日韩国产一二三| 极品尤物av久久免费看| 亚洲欧洲在线观看av| 3d动漫精品啪啪一区二区竹菊| 国产在线一区观看| 亚洲精品综合在线| 91精品国产一区二区三区蜜臀| 国产精品1区2区3区在线观看| 一区二区三区中文在线| 精品人在线二区三区| 99久久免费精品| 奇米影视在线99精品| 亚洲欧洲精品一区二区三区不卡| 欧美亚洲动漫精品| 国产精品正在播放| 亚洲综合成人在线视频| 2024国产精品| 在线亚洲精品福利网址导航| 精品一区二区三区影院在线午夜| 国产精品无人区| 欧美一级爆毛片| 色婷婷久久一区二区三区麻豆| 麻豆91精品视频| 一区二区三区免费| 久久午夜电影网| 欧美精品三级在线观看| 99re66热这里只有精品3直播| 美腿丝袜亚洲综合| 亚洲精品国产一区二区三区四区在线 | 亚洲精品国产一区二区三区四区在线| 日韩欧美的一区| 在线观看成人免费视频| 国产麻豆视频一区二区| 性欧美疯狂xxxxbbbb| 国产精品久久久久毛片软件| 日韩一区二区免费视频| 91久久奴性调教| 国产福利一区二区三区视频在线| 午夜一区二区三区在线观看| 久久久久久久久久久久久夜| 欧美另类高清zo欧美| 色综合久久综合网| 丰满岳乱妇一区二区三区| 免费xxxx性欧美18vr| 亚洲一区二区三区激情| 国产精品久久久久7777按摩| 亚洲精品在线观看网站| 91麻豆精品国产| 欧美亚洲一区二区三区四区| 白白色 亚洲乱淫| 国产毛片精品国产一区二区三区| 日韩avvvv在线播放| 一区二区三区日本| 亚洲免费观看在线观看| 欧美激情一二三区| 久久精品一区四区| 精品剧情在线观看| 这里只有精品电影| 欧美日韩免费视频| 在线观看不卡视频| 欧美在线观看18| 色就色 综合激情| 91丝袜美腿高跟国产极品老师 | 亚洲一区二区三区在线播放| |精品福利一区二区三区| 中文av一区二区| 欧美国产精品一区| 国产日韩欧美精品一区| 国产日韩综合av| 国产区在线观看成人精品| 337p日本欧洲亚洲大胆色噜噜| 日韩免费看的电影| 精品美女一区二区三区| 精品福利一二区| 欧美精品一区二区三区很污很色的 | 一色桃子久久精品亚洲| 一区二区中文视频| 亚洲精品乱码久久久久久久久| 亚洲精品乱码久久久久久久久 | 欧美日韩1234| 欧美另类高清zo欧美| 欧美一区二区三区性视频| 日韩欧美国产一区在线观看| 日韩精品一区二| 久久影院午夜论| 中文一区二区在线观看| 国产精品麻豆视频| 一区二区在线观看免费| 亚洲成在人线在线播放| 日本v片在线高清不卡在线观看| 伦理电影国产精品| 国产一区在线看|