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

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

?? knightstour.java~65~

?? 這是本科生的畢業設計
?? JAVA~65~
字號:
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一区二区三区免费野_久草精品视频
亚洲欧洲日韩综合一区二区| 国产三级欧美三级日产三级99| 成人av网站大全| 国产suv一区二区三区88区| 国产一区二区日韩精品| 国产精品一区在线观看乱码| 国产一区二区三区在线观看免费| 蜜臀av国产精品久久久久| 蜜桃av一区二区三区| 卡一卡二国产精品| 国产一区二区美女| 成人av在线资源网| 色菇凉天天综合网| 欧美精品丝袜中出| 26uuu欧美| 国产精品久久久久aaaa樱花| 一区二区三区欧美激情| 午夜私人影院久久久久| 激情偷乱视频一区二区三区| 高清在线不卡av| 欧美亚洲自拍偷拍| 日韩午夜精品电影| 亚洲欧洲精品天堂一级| 亚洲国产一二三| 国产在线视频精品一区| 色综合久久中文综合久久97| 69精品人人人人| 国产欧美日韩激情| 亚洲成av人片在www色猫咪| 国内精品嫩模私拍在线| 色哦色哦哦色天天综合| 日韩欧美国产麻豆| 亚洲品质自拍视频| 激情亚洲综合在线| 日韩亚洲欧美在线观看| 欧美激情一区不卡| 粉嫩蜜臀av国产精品网站| 久久久久久久综合日本| 国产99久久久国产精品潘金| 中文字幕av一区二区三区高| 成人激情校园春色| 亚洲综合精品自拍| 777久久久精品| 韩国成人福利片在线播放| 久久婷婷色综合| av网站一区二区三区| 亚洲精品欧美激情| 欧美精品一级二级三级| 欧美96一区二区免费视频| 精品久久久久久亚洲综合网| 国产精品资源在线看| 国产精品成人午夜| 欧美日韩不卡一区二区| 九九国产精品视频| 国产精品每日更新在线播放网址| 91网上在线视频| 日韩激情av在线| 久久综合九色欧美综合狠狠| 成人激情av网| 丝袜国产日韩另类美女| 久久久久久一二三区| 91福利视频网站| 老司机精品视频一区二区三区| 欧美国产日韩亚洲一区| 欧美性猛交xxxx黑人交| 精品亚洲欧美一区| 亚洲精品日韩专区silk| 精品sm在线观看| 99精品一区二区| 久久激情五月婷婷| 亚洲免费观看高清完整版在线 | 91精品国产欧美一区二区| 精品在线免费观看| 亚洲激情图片一区| 国产亚洲自拍一区| 欧美日韩国产精品成人| 成人av电影在线| 久久精品国产亚洲高清剧情介绍 | 日本精品免费观看高清观看| 免费成人美女在线观看| 亚洲品质自拍视频网站| 久久久久久久久久电影| 欧美三级在线播放| 91在线精品一区二区三区| 久久精品国产99国产| 亚洲综合在线免费观看| 欧美激情综合网| 精品国产麻豆免费人成网站| 欧美午夜一区二区| 91捆绑美女网站| 成人国产视频在线观看| 国产乱国产乱300精品| 热久久国产精品| 午夜精品国产更新| 亚洲精品成人少妇| 亚洲欧美日韩一区二区三区在线观看 | 91国在线观看| 国产精品456| 久久电影国产免费久久电影 | 日本va欧美va精品发布| 一区二区三区美女视频| 亚洲色图欧美在线| 亚洲三级理论片| 国产精品你懂的在线| 日韩欧美黄色影院| 欧美一区二区精品久久911| 欧美色区777第一页| 99国产精品一区| 亚洲国产精品久久艾草纯爱| 狠狠色丁香久久婷婷综合_中| 一卡二卡欧美日韩| 国产精品网站在线播放| 91蜜桃在线免费视频| 亚洲在线观看免费| 欧美日韩国产123区| 欧美精品 国产精品| 91国偷自产一区二区三区成为亚洲经典 | 免费成人美女在线观看.| 成人免费视频在线观看| 欧美经典一区二区| 国产精品女同一区二区三区| 国产清纯在线一区二区www| 国产欧美精品一区二区色综合朱莉 | 久久精品一区蜜桃臀影院| 久久综合狠狠综合| 国产欧美一区二区精品性色| 久久久亚洲综合| 欧美激情一区二区在线| ...av二区三区久久精品| 亚洲美女屁股眼交| 亚洲第一会所有码转帖| 美女视频黄 久久| 国模无码大尺度一区二区三区| 激情图片小说一区| 成人激情黄色小说| 欧美午夜一区二区三区| 日韩欧美中文一区二区| 久久久99精品久久| 亚洲视频小说图片| 日日骚欧美日韩| 国产一区啦啦啦在线观看| 色域天天综合网| 欧美一卡二卡三卡四卡| 国产欧美视频一区二区三区| 亚洲精品国产第一综合99久久| 日本欧美大码aⅴ在线播放| 激情都市一区二区| 在线欧美日韩国产| 久久综合丝袜日本网| 亚洲综合清纯丝袜自拍| 精品无人码麻豆乱码1区2区| 色综合天天综合给合国产| 日韩情涩欧美日韩视频| 亚洲女人****多毛耸耸8| 久久精品国产精品亚洲红杏 | 欧美一区二区三区白人| 国产午夜精品久久久久久免费视| 一区二区三区欧美亚洲| 韩国av一区二区三区在线观看| 91在线观看免费视频| 日韩午夜中文字幕| 亚洲精品成人精品456| 国产精品白丝jk黑袜喷水| 欧美日韩在线播放三区四区| 国产日韩一级二级三级| 亚洲高清免费观看| 99久久精品国产一区| 日韩欧美亚洲另类制服综合在线| 亚洲欧美国产毛片在线| 国产麻豆精品视频| 欧美艳星brazzers| 亚洲欧洲另类国产综合| 久久国产精品99精品国产| 欧美日韩不卡一区二区| 亚洲国产精品精华液ab| 韩国av一区二区三区在线观看| 欧美吻胸吃奶大尺度电影 | 国产传媒久久文化传媒| 日本电影亚洲天堂一区| 久久99精品久久久久久| 一片黄亚洲嫩模| 在线观看免费一区| 亚洲精品中文在线| 国产成人免费在线观看不卡| 欧美激情自拍偷拍| www.色综合.com| 国产麻豆91精品| 一区二区视频免费在线观看| 欧美一级理论性理论a| 91一区二区在线观看| 国产aⅴ精品一区二区三区色成熟| 亚洲一区中文在线| 亚洲一区二区三区视频在线播放| 久久亚洲精品国产精品紫薇| 日韩欧美国产综合| 91精品国产综合久久国产大片| 日本高清免费不卡视频| 菠萝蜜视频在线观看一区| 国产一二精品视频| 国产宾馆实践打屁股91|