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

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

?? knightstour.java~68~

?? Java課程設計案例精編光盤源碼
?? JAVA~68~
字號:
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 int startx ;   private int starty ;   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 ;//         if ( ( ( Math.abs( xpos -startx ) == 1)  & ( Math.abs ( ypos - starty ) ==2 ) ) |  //            ( ( Math.abs( xpos -startx ) == 2)  & ( Math.abs ( ypos - starty ) ==1 ) ) )         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;            startx = row ;            starty = column ;            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一区二区三区免费野_久草精品视频
日日嗨av一区二区三区四区| 在线成人免费观看| 亚洲一区在线观看免费观看电影高清| 久久综合九色综合欧美亚洲| 久久er精品视频| 日韩亚洲欧美一区| 久久福利视频一区二区| 2024国产精品| 成人免费av资源| 亚洲欧美另类小说视频| 欧美日韩精品是欧美日韩精品| 国产xxx精品视频大全| 日本一区二区三区久久久久久久久不| 99麻豆久久久国产精品免费优播| 亚洲综合在线电影| 欧美日韩高清影院| 韩国精品主播一区二区在线观看| 中文字幕av免费专区久久| 一本大道综合伊人精品热热| 亚洲第一福利一区| 精品久久久久香蕉网| 不卡免费追剧大全电视剧网站| 亚洲激情图片小说视频| 日韩午夜激情电影| 成人国产精品免费观看| 亚洲一区二区三区四区不卡| 337p粉嫩大胆色噜噜噜噜亚洲| 波多野结衣一区二区三区| 性做久久久久久免费观看欧美| 精品久久久久久最新网址| 成人av动漫网站| 日韩精品电影在线| 欧美国产一区视频在线观看| 欧美性感一区二区三区| 国产精品一色哟哟哟| 亚洲欧美一区二区三区极速播放| 欧美久久免费观看| 国产成人免费9x9x人网站视频| 一区二区三区精品久久久| 欧美xingq一区二区| 91亚洲国产成人精品一区二三| 日本不卡一区二区三区高清视频| 国产欧美日韩三级| 欧美久久久一区| 成人h精品动漫一区二区三区| 午夜精品在线视频一区| 国产精品传媒视频| 日韩欧美你懂的| 色综合天天综合色综合av | 日韩精品最新网址| 91麻豆福利精品推荐| 狠狠色丁香婷婷综合| 亚洲愉拍自拍另类高清精品| 国产午夜精品久久久久久久| 欧美美女一区二区| 99免费精品视频| 久草精品在线观看| 午夜影院久久久| 中文字幕久久午夜不卡| 日韩你懂的电影在线观看| 色婷婷激情一区二区三区| 国产剧情一区在线| 青青草国产精品97视觉盛宴| 亚洲欧美日韩系列| 欧美高清在线精品一区| 欧美成人综合网站| 欧美日韩综合色| 成人av网站在线| 久99久精品视频免费观看| 亚洲国产成人av| 中文字幕一区二区三| 久久久精品中文字幕麻豆发布| 欧美日韩一级二级| 国产jizzjizz一区二区| 欧美中文字幕一区二区三区亚洲| 欧美成人精品二区三区99精品| 亚洲黄色录像片| 国产精品99久久久久久有的能看| 成人动漫视频在线| 久久久久久亚洲综合影院红桃 | 国产蜜臀97一区二区三区| 国产最新精品免费| 日韩理论片网站| 久久亚洲二区三区| 欧美日韩精品一区二区三区蜜桃| 99re热这里只有精品视频| 成人精品鲁一区一区二区| 国产91露脸合集magnet| 国产一区二区在线观看免费| 国产精品一区三区| 一区二区三区国产精华| 欧美国产精品一区二区| 久久久久国产精品免费免费搜索| 日韩欧美资源站| 777xxx欧美| 欧美高清激情brazzers| 91福利社在线观看| 色哦色哦哦色天天综合| 91网上在线视频| 91丨porny丨户外露出| 91视频免费观看| 色悠悠亚洲一区二区| 91在线小视频| 91香蕉国产在线观看软件| 91视频免费播放| 91国产视频在线观看| 在线视频国内一区二区| 色av一区二区| 欧美午夜视频网站| 欧美麻豆精品久久久久久| 欧美精品丝袜中出| 91精品国产麻豆国产自产在线| **欧美大码日韩| 国产精品免费人成网站| 综合精品久久久| 亚洲精品国产成人久久av盗摄| 亚洲精品成人天堂一二三| 亚洲国产一区二区三区青草影视 | 中文字幕在线观看不卡| 亚洲日本韩国一区| 一区二区三区免费网站| 亚洲成人手机在线| 日日夜夜精品免费视频| 麻豆成人久久精品二区三区小说| 麻豆极品一区二区三区| 国产一区二区三区精品欧美日韩一区二区三区 | a亚洲天堂av| 91丨porny丨蝌蚪视频| 欧美视频一区二区在线观看| 777午夜精品视频在线播放| 91精品国产色综合久久不卡蜜臀| 日韩欧美一区二区不卡| 久久久久久免费网| 国产精品不卡视频| 亚洲国产精品一区二区www | 日韩一区二区三区高清免费看看| 日韩欧美亚洲国产精品字幕久久久| www国产亚洲精品久久麻豆| 中文成人综合网| 亚洲精品国产精华液| 日韩国产一二三区| 国产麻豆欧美日韩一区| 91视视频在线观看入口直接观看www | 韩日av一区二区| 成人ar影院免费观看视频| 欧美主播一区二区三区美女| 日韩欧美激情四射| 中文字幕精品在线不卡| 亚洲欧美偷拍卡通变态| 日本在线不卡视频一二三区| 国产一区二区不卡老阿姨| 色婷婷综合久久久中文字幕| 日韩一区二区三区在线| 国产精品色一区二区三区| 午夜视频在线观看一区二区三区| 久久国产夜色精品鲁鲁99| 成人高清av在线| 69堂精品视频| 中文字幕不卡在线观看| 亚洲国产三级在线| 国产一本一道久久香蕉| 在线观看www91| 日韩免费成人网| 日韩毛片视频在线看| 美腿丝袜亚洲色图| 99久久国产综合精品麻豆| 欧美一区二区女人| 中文字幕亚洲视频| 久久成人免费电影| 91麻豆福利精品推荐| 精品国产一区二区在线观看| 亚洲男人的天堂av| 韩国成人福利片在线播放| 欧美影院一区二区| 国产日韩欧美高清在线| 日韩高清中文字幕一区| av不卡免费在线观看| 精品久久久久久无| 一区二区三区国产豹纹内裤在线 | 91看片淫黄大片一级在线观看| 在线播放一区二区三区| 1024成人网色www| 美日韩一区二区| 欧美性受xxxx| 中文字幕av免费专区久久| 久久精品国产精品亚洲红杏| 91视频免费观看| 国产欧美一区视频| 免费看欧美女人艹b| 色88888久久久久久影院野外| 2023国产精品| 视频在线观看一区二区三区| 欧美激情在线看| 五月天国产精品| 色吧成人激情小说| 国产精品久久久久久久第一福利| 久久国产精品无码网站| 欧美日韩一区二区在线观看| 国产精品传媒入口麻豆| 国产精品亚洲成人|