亚洲欧美第一页_禁久久精品乱码_粉嫩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不卡在线播放| 久久先锋影音av鲁色资源| 图片区小说区区亚洲影院| 99这里都是精品| 国产欧美一区二区精品婷婷| 日韩电影在线免费观看| 色素色在线综合| 日本一区二区免费在线| 久久99国产乱子伦精品免费| 欧美群妇大交群中文字幕| 依依成人综合视频| 色综合久久久久综合体桃花网| 欧美极品aⅴ影院| 国产不卡视频在线观看| 久久久91精品国产一区二区精品| 免费在线观看成人| 日韩午夜小视频| 琪琪久久久久日韩精品| 91精品国产色综合久久ai换脸| 亚洲一区在线看| 欧美日韩在线播放| 亚洲va韩国va欧美va精品| 欧美在线不卡一区| 亚洲综合色噜噜狠狠| 在线观看日韩国产| 午夜视频在线观看一区| 51久久夜色精品国产麻豆| 亚洲欧美国产三级| 国产日韩精品一区二区三区 | 日韩一级免费观看| 手机精品视频在线观看| 777精品伊人久久久久大香线蕉| 午夜精品视频在线观看| 欧美一区二区三区视频| 日本午夜一区二区| 久久久91精品国产一区二区精品 | 欧美三级在线视频| 丝袜亚洲精品中文字幕一区| 日韩一区二区三免费高清| 久久99国产乱子伦精品免费| 久久久国产综合精品女国产盗摄| 国产成人自拍在线| 1区2区3区欧美| 在线电影一区二区三区| 精久久久久久久久久久| 国产精品美女久久久久av爽李琼 | 依依成人精品视频| 69堂亚洲精品首页| 国产在线精品国自产拍免费| 国产精品免费av| 欧美四级电影网| 看片网站欧美日韩| 中文字幕一区日韩精品欧美| 欧美性三三影院| 国产在线精品一区二区不卡了| 一区二区中文字幕在线| 欧美日韩日日骚| 国产九九视频一区二区三区| 亚洲另类在线制服丝袜| 日韩视频免费直播| 99久久综合99久久综合网站| 婷婷成人综合网| 中文字幕乱码久久午夜不卡| 欧美精品电影在线播放| 国产黄人亚洲片| 天天射综合影视| 国产精品乱人伦| 日韩一级片网址| 91免费看片在线观看| 老司机免费视频一区二区 | 丝袜诱惑亚洲看片| 国产精品久久久久久久久免费丝袜| 欧美私模裸体表演在线观看| 丁香六月综合激情| 免费观看在线综合色| 玉米视频成人免费看| 中文字幕高清不卡| 精品久久久久99| 欧美日产国产精品| 色综合中文字幕| 国产寡妇亲子伦一区二区| 日韩精品电影在线观看| 亚洲视频一区二区免费在线观看| 久久久久97国产精华液好用吗| 91精品国产手机| 欧美三级中文字幕在线观看| 91麻豆swag| av网站免费线看精品| 国产一区二区三区电影在线观看 | 亚洲成人av资源| 亚洲免费观看高清| 国产精品久久网站| 欧美经典一区二区三区| 久久久不卡网国产精品二区| 精品久久久久久综合日本欧美| 欧美另类变人与禽xxxxx| 91色综合久久久久婷婷| 国产成人亚洲综合a∨猫咪| 韩国成人在线视频| 另类成人小视频在线| 裸体歌舞表演一区二区| 免费高清视频精品| 另类的小说在线视频另类成人小视频在线| 亚洲国产一区二区a毛片| 亚洲精品高清在线| 亚洲一区二区三区自拍| 亚洲一区二区美女| 亚洲成a人片在线不卡一二三区 | 一区二区三区在线看| 亚洲少妇屁股交4| 亚洲日本va午夜在线影院| 自拍偷自拍亚洲精品播放| 国产精品久久影院| 亚洲精品少妇30p| 亚洲第一精品在线| 日本最新不卡在线| 黄色精品一二区| 国产·精品毛片| 99国产精品久| 精品视频1区2区| 制服丝袜亚洲色图| 欧美刺激午夜性久久久久久久| 欧美精品一区二区三区视频| 久久久精品黄色| 国产精品久久久久一区二区三区共| 亚洲人吸女人奶水| 午夜精品久久久久影视| 蜜臀av一级做a爰片久久| 国产精品亚洲综合一区在线观看| 不卡的av网站| 欧美日韩第一区日日骚| 精品久久国产字幕高潮| 国产精品三级电影| 午夜精品爽啪视频| 激情综合色综合久久| 成人黄色网址在线观看| 在线观看欧美精品| 欧美xfplay| 一区二区三区在线视频免费观看| 日韩福利电影在线| 福利一区福利二区| 欧美日韩中文国产| 国产欧美一区二区精品性色| 亚洲免费在线观看| 国产揄拍国内精品对白| 色哟哟在线观看一区二区三区| 日韩欧美一级特黄在线播放| 亚洲天堂2014| 国精产品一区一区三区mba桃花| 96av麻豆蜜桃一区二区| 日韩免费高清电影| 亚洲欧美精品午睡沙发| 另类专区欧美蜜桃臀第一页| 色综合视频在线观看| 欧美精品一区二区久久婷婷| 亚洲综合在线免费观看| 国产91精品久久久久久久网曝门 | 精品制服美女久久| 在线观看av不卡| 中文字幕一区二区三区蜜月| 美女网站视频久久| 在线观看一区二区视频| 中文字幕免费不卡在线| 久久97超碰国产精品超碰| 91啪在线观看| 欧美国产日产图区| 九九九精品视频| 欧美三级资源在线| 亚洲欧美另类在线| 成人午夜又粗又硬又大| 精品国产免费人成在线观看| 亚洲图片有声小说| 99re热视频这里只精品 | 制服丝袜日韩国产| 亚洲精品视频在线观看网站| 国产盗摄一区二区| 亚洲精品一区二区三区香蕉| 免费一级片91| 91麻豆精品国产91久久久更新时间 | 99久久精品国产一区二区三区 | 91精品国产欧美一区二区成人| 亚洲激情成人在线| 一本久久综合亚洲鲁鲁五月天| 中文字幕精品一区| 成人国产亚洲欧美成人综合网| 国产丝袜在线精品| 国产一区二区成人久久免费影院| 欧美va亚洲va| 国产一区二区三区免费在线观看| 欧美一区二区三区小说| 蜜桃av一区二区在线观看| 日韩欧美一区中文| 久久超碰97人人做人人爱| 精品久久99ma| 国产成人精品综合在线观看 |