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

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

?? knightstour.java~63~

?? Java課程設計,介紹及代碼,Java課程設計,介紹及代碼.
?? JAVA~63~
字號:
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 ] );                  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一区二区三区免费野_久草精品视频
日本一区二区三区四区| 日韩av一区二区三区四区| 午夜视频一区在线观看| 国产一区二区调教| 色婷婷狠狠综合| 久久精品视频免费| 男女男精品视频| 欧美在线观看一区二区| 国产精品久久一卡二卡| 国产做a爰片久久毛片| 911国产精品| 亚洲综合一区二区精品导航| 懂色av一区二区三区免费看| 精品乱人伦小说| 热久久久久久久| 欧美日韩午夜精品| 亚洲欧美电影院| eeuss鲁片一区二区三区在线看| 日韩精品在线一区二区| 日日夜夜精品视频免费| 欧美性受xxxx黑人xyx| 亚洲天堂网中文字| 波多野结衣中文一区| 久久综合99re88久久爱| 久久精品国产秦先生| 在线播放视频一区| 日韩av在线发布| 制服丝袜亚洲色图| 日韩有码一区二区三区| 欧美日韩一级二级三级| 午夜久久久久久电影| 精品成人一区二区三区| 日韩不卡在线观看日韩不卡视频| 欧美亚洲禁片免费| 亚洲午夜激情网页| 8v天堂国产在线一区二区| 婷婷六月综合网| 欧美一级免费观看| 捆绑调教美女网站视频一区| 日韩精品在线网站| 国产成人综合精品三级| 欧美极品另类videosde| 99精品在线免费| 一区二区三区在线视频观看58 | 久久久www成人免费毛片麻豆| 麻豆成人在线观看| 久久人人97超碰com| 成人国产精品免费网站| 亚洲美女一区二区三区| 欧美日韩午夜精品| 老汉av免费一区二区三区| 久久婷婷色综合| fc2成人免费人成在线观看播放| 自拍偷拍亚洲激情| 欧美久久久久中文字幕| 韩国av一区二区三区在线观看| 国产视频在线观看一区二区三区| 99这里只有精品| 亚洲第四色夜色| 久久无码av三级| 日本韩国一区二区三区视频| 日韩电影免费在线| 中文字幕第一区综合| 在线看日本不卡| 久久国产精品色| 亚洲欧洲韩国日本视频| 51精品秘密在线观看| 国产成人日日夜夜| 亚洲一二三区视频在线观看| 精品国产一区二区三区不卡 | 欧美日韩一区三区| 黄网站免费久久| 亚洲女人小视频在线观看| 88在线观看91蜜桃国自产| 成人黄色小视频| 日韩黄色免费电影| 亚洲天堂av老司机| 精品动漫一区二区三区在线观看| 91麻豆免费观看| 精品一区二区免费在线观看| 亚洲激情图片一区| 国产亚洲va综合人人澡精品| 欧美丰满高潮xxxx喷水动漫| 99riav一区二区三区| 狠狠网亚洲精品| 婷婷开心激情综合| 亚洲激情综合网| 国产精品视频免费看| 欧美一二三区在线| 国产精品蜜臀在线观看| 制服.丝袜.亚洲.中文.综合| 99re这里都是精品| 成人一区二区三区在线观看| 男人的天堂久久精品| 亚洲成人免费在线观看| 国产精品久久国产精麻豆99网站| 精品国产免费久久| 69堂精品视频| 欧美日韩一二三区| 精品视频1区2区| 色94色欧美sute亚洲线路一久| 丁香婷婷综合激情五月色| 国产在线播精品第三| 日韩高清国产一区在线| 亚洲电影第三页| 亚洲综合成人在线视频| 亚洲人成7777| 亚洲麻豆国产自偷在线| 亚洲伦理在线免费看| 亚洲视频综合在线| 亚洲免费大片在线观看| 国产精品高清亚洲| 自拍偷自拍亚洲精品播放| 欧美激情中文不卡| 久久亚区不卡日本| 久久午夜免费电影| 国产午夜精品理论片a级大结局| 精品国产免费一区二区三区香蕉| 日韩欧美一区在线| 日韩欧美国产高清| 久久综合色播五月| 久久久精品国产免费观看同学| 久久综合久久综合九色| 久久综合色综合88| 亚洲国产精品国自产拍av| 国产亚洲精品7777| 欧美激情一区二区三区全黄| 国产精品情趣视频| 亚洲视频在线观看一区| 亚洲综合丝袜美腿| 免费成人av资源网| 国产福利一区二区三区| 国产**成人网毛片九色| 99久久国产综合色|国产精品| 色老综合老女人久久久| 中文字幕精品在线不卡| 亚洲黄一区二区三区| 天堂在线一区二区| 国内欧美视频一区二区| 99精品久久久久久| 欧美日本视频在线| 精品国产不卡一区二区三区| 中文字幕乱码日本亚洲一区二区| 亚洲免费观看高清在线观看| 婷婷成人综合网| 国产成人午夜99999| 欧美影视一区在线| 日韩一级精品视频在线观看| 亚洲精品一区二区三区蜜桃下载| 中文字幕亚洲一区二区va在线| 亚洲国产一区二区三区| 久久99精品国产麻豆婷婷| 波波电影院一区二区三区| 欧美狂野另类xxxxoooo| 久久精品夜色噜噜亚洲a∨| 亚洲精品国产精品乱码不99| 精品一区二区免费| 一本大道综合伊人精品热热| 精品少妇一区二区| 一区二区三区不卡视频| 国产盗摄精品一区二区三区在线| 在线免费观看日本一区| 国产肉丝袜一区二区| 香蕉加勒比综合久久| 成人av资源下载| 欧美精品一区二区三区久久久| 亚洲综合图片区| 成人av免费网站| 日韩视频123| 亚洲国产精品嫩草影院| 成人av综合一区| 久久久久久亚洲综合影院红桃| 亚洲成人激情av| av午夜精品一区二区三区| 日韩视频一区在线观看| 亚洲综合在线视频| av在线不卡电影| 国产丝袜欧美中文另类| 久久国产精品色| 欧美一级黄色录像| 五月婷婷综合激情| 精品处破学生在线二十三| 亚洲va欧美va天堂v国产综合| 91在线视频网址| 中文在线免费一区三区高中清不卡| 捆绑变态av一区二区三区| 欧美伊人久久久久久久久影院 | 成人18视频日本| 日韩欧美国产综合在线一区二区三区| 亚洲美女在线国产| 91在线观看成人| 综合色天天鬼久久鬼色| av资源网一区| 国产精品免费久久| 盗摄精品av一区二区三区| 欧美国产禁国产网站cc| 粉嫩一区二区三区性色av| 国产蜜臀av在线一区二区三区| 国产精品综合av一区二区国产馆| 欧美sm美女调教|