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

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

?? knightstour.java~59~

?? JAVA原代碼 JAVA原代碼
?? JAVA~59~
字號:
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.showNext() ;               }            }            );//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一区二区三区免费野_久草精品视频
韩国精品一区二区| 亚洲综合久久久久| 中文字幕第一区第二区| 亚洲欧美中日韩| 亚洲国产精品一区二区www| 久久精品国产一区二区| 国产成人在线电影| 精品视频1区2区3区| 欧美成人精品福利| 亚洲精品国久久99热| 美国一区二区三区在线播放| 成人99免费视频| 69堂成人精品免费视频| 欧美国产视频在线| 午夜精品一区二区三区电影天堂| 国产精品一区在线观看你懂的| 色婷婷综合久久久| 亚洲精品在线免费播放| 亚洲精品国产无天堂网2021| 精品一区免费av| 日本黄色一区二区| 国产日韩精品久久久| 亚洲国产视频在线| 北条麻妃一区二区三区| 日韩欧美在线网站| 亚洲精品成人在线| 国产中文字幕精品| 视频一区二区三区中文字幕| 亚洲精品午夜久久久| 久久精品视频网| 亚洲午夜久久久久| 福利一区二区在线观看| 欧美肥妇free| 亚洲女同ⅹxx女同tv| 国产成人午夜99999| 宅男在线国产精品| 亚洲男同性视频| 国产成人高清在线| 精品日韩一区二区| 性欧美疯狂xxxxbbbb| 91免费观看视频在线| 日本一区二区成人在线| 久久精品999| 欧美精品少妇一区二区三区| 亚洲丝袜自拍清纯另类| 国产精品亚洲一区二区三区在线| 欧美一卡2卡3卡4卡| 亚洲gay无套男同| 色国产精品一区在线观看| 国产精品久久久一本精品| 久久福利视频一区二区| 欧美老肥妇做.爰bbww视频| ㊣最新国产の精品bt伙计久久| 国产美女在线观看一区| 日韩欧美国产一二三区| 亚洲成人一二三| 蜜桃久久久久久| 欧洲激情一区二区| ㊣最新国产の精品bt伙计久久| 国产精品亚洲一区二区三区妖精 | 国产亚洲一区二区三区在线观看| 日韩电影在线观看网站| 欧洲av在线精品| 亚洲人成小说网站色在线| 成人aaaa免费全部观看| 国产精品美女视频| av午夜一区麻豆| 国产精品成人免费在线| 成人动漫视频在线| 国产精品每日更新在线播放网址| 国产乱码精品一品二品| 国产清纯白嫩初高生在线观看91| 国产一区二区精品久久91| 久久精品欧美一区二区三区麻豆 | 久久久精品tv| 国产真实乱对白精彩久久| 久久色.com| 国产麻豆一精品一av一免费| 久久久久成人黄色影片| 国产高清精品久久久久| 日本一二三四高清不卡| 99精品欧美一区| 亚洲一区二区三区四区五区黄 | 日韩二区三区在线观看| 欧美一区二区福利在线| 久久99久久精品| 久久精品亚洲一区二区三区浴池| 国产一区二三区好的| 国产日韩成人精品| 91亚洲精品久久久蜜桃网站 | 884aa四虎影成人精品一区| 日韩成人免费电影| 久久影院午夜论| av一本久道久久综合久久鬼色| 亚洲免费在线视频| 欧美日韩成人激情| 加勒比av一区二区| 国产精品久久免费看| 欧美伊人久久久久久午夜久久久久| 婷婷国产在线综合| 日韩国产欧美在线观看| 午夜精品久久久| 免费在线观看成人| 国产一区二区看久久| 国产精品另类一区| 色狠狠桃花综合| 美女脱光内衣内裤视频久久网站| 久久亚洲影视婷婷| 91麻豆免费在线观看| 偷拍亚洲欧洲综合| 亚洲二区视频在线| 日韩美女视频一区二区在线观看| 国产成人免费在线视频| 一区二区三区四区精品在线视频 | 一区二区三区中文字幕电影| 国产乱码精品1区2区3区| 亚洲乱码一区二区三区在线观看| 91麻豆精品国产91久久久使用方法| 九九精品视频在线看| 亚洲男人的天堂在线aⅴ视频| 欧美一区二区黄色| 99久久99久久精品免费观看| 日韩精品国产欧美| 国产精品第五页| 欧美成人性战久久| 日本丶国产丶欧美色综合| 激情图片小说一区| 亚洲风情在线资源站| 国产亚洲一二三区| 欧美人妇做爰xxxⅹ性高电影| 国产成人在线观看免费网站| 婷婷夜色潮精品综合在线| 中文文精品字幕一区二区| 欧美一区二区三区精品| 91丝袜美腿高跟国产极品老师 | 欧美精品一区二区三区四区| 91行情网站电视在线观看高清版| 久久精品99国产精品| 亚洲一二三四在线观看| 国产精品嫩草99a| 欧美成人一区二区三区在线观看| 日本福利一区二区| 高清成人在线观看| 久久精品国产秦先生| 亚洲成人资源在线| 中文字幕亚洲不卡| 久久久久国产精品麻豆ai换脸| 欧美精品丝袜中出| 91九色02白丝porn| 成人禁用看黄a在线| 国产在线乱码一区二区三区| 亚欧色一区w666天堂| 一区二区三区在线影院| 国产日韩在线不卡| 久久日一线二线三线suv| 日韩一级高清毛片| 欧美精品日韩一区| 在线免费观看不卡av| 91亚洲大成网污www| 国产成人高清视频| 国产一二三精品| 九九**精品视频免费播放| 日韩激情一区二区| 亚洲高清在线精品| 亚洲国产精品久久久久秋霞影院| 国产精品亲子伦对白| 亚洲国产高清在线观看视频| 亚洲一区精品在线| 在线成人免费视频| 欧美视频一区二| 成人一区二区视频| 国产激情视频一区二区在线观看 | 日韩一区二区三区在线观看| 欧美日韩免费观看一区三区| 一本一道综合狠狠老| 91在线码无精品| 99久久精品国产一区二区三区| 国产成人av电影在线观看| 国产美女久久久久| 国产精品一区久久久久| 国产一区二区三区黄视频| 国产一区二区三区高清播放| 国内精品免费在线观看| 激情五月播播久久久精品| 久久草av在线| 国模大尺度一区二区三区| 狠狠色丁香婷婷综合| 国产一区二区三区日韩| 国产激情91久久精品导航 | 亚洲色图一区二区| 亚洲三级电影网站| 亚洲午夜视频在线| 肉丝袜脚交视频一区二区| 五月激情综合网| 日一区二区三区| 精品一区二区三区免费视频| 国产一区二区0| 成人h动漫精品一区二| 93久久精品日日躁夜夜躁欧美| 色狠狠色狠狠综合|