javaµÝ¹éʵÏÖººÅµËþ
/*
* ººÅµËþ£¬´ÓµÚ1¸öÖù×Ó½èÖúµÚ2¸ùÖù×ÓÒƶ¯µ½µÚ3¸ù
*/
public class TowerOfHano {
private int totle;//×ܹ²ÅÌ×ÓÊýÄ¿
public TowerOfHano(int totle){
this.totle=totle;
}
private void moveOne(int start,int end){
System.out.println("´Ó"+start+"Òƶ¯Ò»¿éÅÌ×Óµ½"+end);
}
private void moveAll(int totle,int start,int temp,int end){
if(totle==1){
moveOne(start,end);
}else{
moveAll(totle-1,start,end,temp);
moveOne(start,end);
moveAll(totle-1,temp,start,end);
}
}
public static void main(String[] args) {
TowerOfHano tower = new TowerOfHano(3);//²âÊÔÈý¿éÅÌ×Ó
tower.moveAll(tower.totle, 1, 2, 3);
}
}
Ïà¹ØÎĵµ£º
ÄÇÌì°á¼ÒµÄʱºò²Å·¢ÏÖÓкܶàµÄ¶«Î÷£¬»¹¼ÇµÃÎÒ¸ÕÀ´µ½±±¾©µÄʱºòÕÒÁË·¿×Ó¾ÍһֱסÔÚÕâÀï¡£¿ªÊ¼Ã¦Âµ×ÅÕÒ¹¤×÷¡£ÕÒµ½Õâ·Ý¹¤×÷µÄʱºò±¾À´ÊÇÏë»»×ÅÄØ£¬Ã¿Ì춼ÊÇ×öһЩÎÄ×Ö¼ÈëµÄ¹¤×÷·¢³îµÄÎÒ£¬²»¹ýÔÚÕâÀïÒ²ÊÇÓз¢Õ¹µÄ»ú»á£¬ÓеÄʱºòÕûÀíһЩ¹ØÓÚÊý¾Ý·½ÃæµÄ£¬ÈÃÐÂÀ´µÄ°ÑÊý¾Ý¼Èëµ½µçÄÔÉÏ£¬ÎÒÃÇÒ²ÊÇ×öÍâ°üµÄ¡£µ«Ê ......
thisµÄÓ÷¨ÔÚjavaÖдóÌå¿ÉÒÔ·ÖΪ3ÖÖ£º
//1.ÆÕͨµÄÖ±½ÓÒýÓÃ
class test {
private int x,y;
public test(int x,int y) {
setX(x);//Ò²¿ÉÒÔдΪthis.setX(x);ÕâÖÖÇé¿öÏÂthis¿ÉÒÔÊ¡ÂÔ.
}
}
//2.·½·¨ÖеÄij¸öÐβÎÃûÓ뵱ǰ¶ÔÏóµÄÄ ......
public class Migong {
private int gard[][]={ {1,1,1,1,0,1,1,1},
{0,0,0,1,1,1,1,1},
......
Ò»¡¢java·ÃÎÊÖÐÎÄOracleÊý¾Ý¿âÉÏÁ¬½ÓµÄUS7ASCIIÊý¾Ý¿â
1¡¢¶Á·½·¨
public String convertLink_DB(String s) {
if(s != null){
try{
byte[] b = s.getBytes();
for(int i=0; i<b.length; i++){
b[i] ......