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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? knightstour.java~61~

?? 課程設(shè)計(jì)案例精編光盤源碼 課程設(shè)計(jì)案例精編光盤源碼
?? JAVA~61~
字號(hào):
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}

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
一区二区三区日韩精品视频| 日韩一级成人av| 亚洲美女电影在线| 色综合久久88色综合天天6| 一区二区三区四区在线播放| 欧美少妇一区二区| 免费观看在线色综合| 久久久国产精华| av成人老司机| 五月婷婷激情综合| 欧美tickling挠脚心丨vk| 粗大黑人巨茎大战欧美成人| 一区二区三区日韩欧美精品| 日韩视频国产视频| 丰满亚洲少妇av| 亚洲制服丝袜av| 精品粉嫩超白一线天av| 91视视频在线直接观看在线看网页在线看| 亚洲伦理在线精品| 日韩一区二区三区三四区视频在线观看| 国内精品写真在线观看| 亚洲视频香蕉人妖| 日韩一级精品视频在线观看| 成人国产精品免费观看动漫| 亚洲第一福利视频在线| 久久青草欧美一区二区三区| 色天天综合色天天久久| 久久疯狂做爰流白浆xx| 亚洲日本在线看| 日韩免费观看高清完整版| 99re这里都是精品| 蜜臀久久99精品久久久久久9 | 在线电影一区二区三区| 国产精品一二三四区| 亚洲国产日韩一区二区| 久久亚洲精品小早川怜子| 欧美午夜精品久久久久久超碰| 精品一区二区三区久久| 亚洲国产成人av网| 国产精品人成在线观看免费| 日韩一区二区电影| 欧美亚洲国产一区在线观看网站| 国产乱一区二区| 免费人成精品欧美精品| 亚洲精品中文在线观看| 国产日韩精品视频一区| 欧美一级二级在线观看| 91黄色免费观看| 成人黄色网址在线观看| 狠狠色狠狠色合久久伊人| 亚洲一级二级在线| 亚洲欧美经典视频| 国产亲近乱来精品视频| 欧美大白屁股肥臀xxxxxx| 欧美日韩一区二区三区在线看| 成人中文字幕电影| 国产做a爰片久久毛片| 青青草原综合久久大伊人精品 | 狠狠色丁香婷婷综合| 亚洲成av人片一区二区梦乃| 亚洲男人的天堂在线aⅴ视频| 欧美精彩视频一区二区三区| 精品国产不卡一区二区三区| 3d动漫精品啪啪1区2区免费| 欧美中文字幕一区二区三区| 91麻豆免费观看| 91污片在线观看| 91丝袜呻吟高潮美腿白嫩在线观看| 国产乱码精品一区二区三| 美女看a上一区| 久久国产精品72免费观看| 久久不见久久见免费视频1| 日韩高清不卡在线| 青青草精品视频| 久久精品国产秦先生| 麻豆91精品91久久久的内涵| 精品亚洲国产成人av制服丝袜| 老汉av免费一区二区三区| 蜜桃视频在线观看一区二区| 蜜桃91丨九色丨蝌蚪91桃色| 蜜桃av一区二区三区电影| 久久精品国产秦先生| 国产成人在线观看| k8久久久一区二区三区| 日本二三区不卡| 制服丝袜在线91| 26uuu亚洲综合色欧美| 日本一区二区视频在线| 亚洲少妇最新在线视频| 一区二区三区四区在线播放 | 欧美区在线观看| 日韩一区二区不卡| 国产日韩欧美麻豆| 亚洲欧美另类综合偷拍| 天天操天天色综合| 国产酒店精品激情| 色综合一区二区| 欧美久久久一区| 精品成a人在线观看| 中文字幕一区二区5566日韩| 亚洲一区二区不卡免费| 免费在线观看一区二区三区| 国产91丝袜在线播放0| 97se亚洲国产综合自在线| 欧美另类z0zxhd电影| 久久久九九九九| 亚洲一区二区三区自拍| 韩国成人精品a∨在线观看| eeuss鲁一区二区三区| 欧美日韩亚洲丝袜制服| 久久久久国产一区二区三区四区| 亚洲欧美在线另类| 免费在线观看不卡| 99国内精品久久| 日韩精品在线看片z| 亚洲免费大片在线观看| 精品亚洲成a人| 欧美日韩黄色一区二区| 欧美激情一区三区| 蜜桃视频一区二区三区| 91美女片黄在线观看91美女| 精品国产乱码久久久久久图片 | 99久久99久久免费精品蜜臀| 欧美一区日本一区韩国一区| 国产精品理伦片| 蜜臀av性久久久久蜜臀aⅴ四虎| 91在线国产福利| 精品国产sm最大网站| 亚洲chinese男男1069| 国产成人av资源| 日韩欧美在线观看一区二区三区| 亚洲欧美怡红院| 国产精品1区2区3区| 欧美一区二区视频在线观看| ●精品国产综合乱码久久久久| 久草中文综合在线| 欧美精选一区二区| 亚洲一区二区在线免费观看视频| 福利一区福利二区| 亚洲精品在线电影| 蜜桃av噜噜一区二区三区小说| 在线观看一区日韩| 成人免费在线视频| 成人黄色综合网站| 久久久精品黄色| 精品亚洲免费视频| 日韩欧美一区在线| 日韩精品免费视频人成| 欧美日韩久久久| 亚洲国产美女搞黄色| 91国产精品成人| 亚洲欧美视频在线观看视频| 成人精品视频一区二区三区| 久久婷婷成人综合色| 久久99精品久久久| 欧美一区二区日韩| 日韩不卡在线观看日韩不卡视频| 欧美三级中文字| 五月婷婷综合在线| 这里只有精品视频在线观看| 午夜欧美一区二区三区在线播放| 一本大道久久a久久精品综合| 国产精品美女www爽爽爽| 成人在线一区二区三区| 亚洲国产精品精华液2区45| 国产成人av影院| 国产精品短视频| 色综合一区二区| 亚洲成人中文在线| 欧美精品1区2区3区| 老司机午夜精品| 国产亚洲精品aa| 不卡一区二区在线| 一区二区三区在线视频播放| 在线观看一区二区视频| 日韩国产精品大片| 久久众筹精品私拍模特| 欧美一级免费大片| 国产精品综合久久| 中文字幕在线一区二区三区| 99麻豆久久久国产精品免费| 亚洲乱码国产乱码精品精98午夜| 欧洲视频一区二区| 麻豆专区一区二区三区四区五区| 精品久久一区二区| 床上的激情91.| 亚洲综合在线免费观看| 欧美一区二区在线免费播放| 国产在线不卡一区| 国产精品国产三级国产有无不卡 | 91精品国产黑色紧身裤美女| 美国欧美日韩国产在线播放| 久久精品在这里| 色欧美88888久久久久久影院| 亚洲午夜在线电影| wwwwxxxxx欧美| 日本韩国精品在线| 狠狠色丁香久久婷婷综合_中| 亚洲欧洲日产国码二区| 欧美一区二区三区免费|