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

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

?? knightstour.java~59~

?? 課程設計案例精編光盤源碼 課程設計案例精編光盤源碼
?? 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一区二区三区免费野_久草精品视频
五月天亚洲婷婷| 欧美最新大片在线看| 狠狠色丁香婷婷综合| 奇米色一区二区| 久久精品99久久久| 久久99久久精品欧美| 另类专区欧美蜜桃臀第一页| 精品在线播放免费| 国模娜娜一区二区三区| 高清不卡一二三区| 91伊人久久大香线蕉| 91亚洲精品乱码久久久久久蜜桃| 91视频免费播放| 色婷婷激情综合| 欧美日韩国产天堂| 日韩欧美第一区| 国产欧美一区视频| **性色生活片久久毛片| 一区二区三区高清| 日本v片在线高清不卡在线观看| 日韩精品午夜视频| 国产一区二区三区免费观看| 粉嫩一区二区三区性色av| 99r精品视频| 欧美精品1区2区3区| 精品少妇一区二区三区日产乱码 | 国产精品1区2区3区| 国产一区亚洲一区| 99精品国产一区二区三区不卡| 色综合天天做天天爱| 欧美人伦禁忌dvd放荡欲情| 日韩欧美久久一区| 国产精品家庭影院| 亚洲高清在线精品| 国产一区二区视频在线播放| 一本色道久久综合亚洲91| 精品视频在线免费看| 精品处破学生在线二十三| 国产精品乱码久久久久久| 亚洲一区二区三区四区的| 青青草精品视频| 成人免费视频播放| 欧美精品一二三区| 欧美极品xxx| 午夜精品福利视频网站| 激情欧美一区二区| 91久久久免费一区二区| 精品国产电影一区二区| 国产精品动漫网站| 免费高清不卡av| av电影在线观看完整版一区二区| 欧美精品一二三四| 国产日韩欧美精品一区| 午夜国产精品影院在线观看| 国产精品99久久久久| 欧美日韩精品欧美日韩精品一 | 播五月开心婷婷综合| 色综合久久久久久久| 精品理论电影在线观看| 亚洲精选免费视频| 国产一区二区精品在线观看| 欧美色涩在线第一页| 欧美国产日本视频| 久久精品久久综合| 欧美丝袜丝交足nylons| 国产精品国产三级国产普通话蜜臀 | 久久99国产精品久久99果冻传媒| 99re6这里只有精品视频在线观看| 欧美大胆一级视频| 亚洲一二三专区| 99久久er热在这里只有精品66| 日韩一区二区免费高清| 一区二区国产盗摄色噜噜| 国产一区二区免费看| 欧美一区二区视频在线观看 | 国产成人午夜电影网| 欧美日韩精品二区第二页| 中文字幕在线不卡视频| 国产一区二区三区免费看| 51精品秘密在线观看| 亚洲综合小说图片| 色偷偷成人一区二区三区91| 国产精品网站在线播放| 国产精品77777| 精品国产成人系列| 午夜精品福利一区二区三区av| 色琪琪一区二区三区亚洲区| 国产精品嫩草影院com| 国产精品夜夜嗨| 久久亚区不卡日本| 九一九一国产精品| 日韩欧美在线观看一区二区三区| 午夜精品福利一区二区三区av | 国产一二精品视频| 精品伦理精品一区| 精品一区二区三区视频在线观看 | 亚洲专区一二三| 91激情在线视频| 亚洲精品日韩综合观看成人91| 成人动漫一区二区在线| 国产精品久久久久久久久久久免费看| 国产精品夜夜嗨| 国产校园另类小说区| 国产a精品视频| 国产精品免费aⅴ片在线观看| 国产成人精品免费一区二区| 国产欧美一区二区三区在线老狼| 高清日韩电视剧大全免费| 中文字幕乱码日本亚洲一区二区| 不卡视频一二三| 亚洲日本成人在线观看| 91丨porny丨蝌蚪视频| 亚洲精品日日夜夜| 欧美日韩黄色影视| 全国精品久久少妇| 久久综合九色综合97_久久久| 国产高清不卡一区| 中文字幕一区视频| 91福利精品视频| 人人精品人人爱| 国产调教视频一区| 成人av网站在线| 亚洲男人的天堂在线aⅴ视频| 91久久精品日日躁夜夜躁欧美| 日韩精品电影在线| 精品久久人人做人人爰| 国产成人精品影视| 一区二区三区免费| 日韩欧美一区二区不卡| 成人免费高清在线| 亚洲一区免费在线观看| 日韩一区二区麻豆国产| 国产69精品一区二区亚洲孕妇| 一区二区三区欧美亚洲| 欧美二区乱c少妇| 日韩一区欧美二区| 久久精品网站免费观看| 91天堂素人约啪| 日本三级韩国三级欧美三级| 亚洲精品在线免费播放| 99久久精品国产观看| 日韩国产欧美视频| 国产精品你懂的在线| 欧美久久一区二区| 国产不卡视频在线播放| 夜夜爽夜夜爽精品视频| 欧美一区二区三区婷婷月色| 国产不卡视频在线播放| 亚洲福利视频三区| 国产色一区二区| 欧美日韩在线免费视频| 国产白丝精品91爽爽久久| 亚洲成a人v欧美综合天堂下载| www精品美女久久久tv| 在线观看日韩毛片| 激情欧美一区二区| 亚洲国产成人av网| 国产精品久久国产精麻豆99网站 | 日韩伦理av电影| 91精品久久久久久久99蜜桃| 粉嫩aⅴ一区二区三区四区| 视频一区中文字幕国产| 国产精品灌醉下药二区| 日韩视频在线永久播放| 91麻豆福利精品推荐| 国内精品伊人久久久久av影院| 亚洲国产美国国产综合一区二区| 国产亚洲成aⅴ人片在线观看| 欧美日韩免费不卡视频一区二区三区| 国产九色sp调教91| 日韩高清国产一区在线| 一区二区在线观看视频| 中文字幕不卡在线播放| 日韩免费观看高清完整版| 欧美体内she精视频| 99视频有精品| 国产乱码精品一区二区三区av | 亚洲乱码国产乱码精品精可以看| 精品久久一区二区三区| 337p亚洲精品色噜噜| 97se亚洲国产综合自在线观| 国产成人午夜视频| 看电影不卡的网站| 日韩高清不卡在线| 香蕉久久夜色精品国产使用方法| 亚洲人精品一区| 国产精品国产馆在线真实露脸| 国产亚洲婷婷免费| 欧美精品一区二区三区高清aⅴ | 欧美女孩性生活视频| 日本高清不卡aⅴ免费网站| 成人黄色在线网站| 国产精品77777竹菊影视小说| 老司机精品视频导航| 青青草国产成人av片免费| 午夜免费久久看| 天天操天天色综合| 亚洲bt欧美bt精品777| 亚洲一区二区视频在线| 伊人色综合久久天天|