Welcome, guest! Login / Register - Why register?
Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)

Paste

Pasted as Java by fdxs ( 15 years ago )
public class türmeVonHanoi {
  int counter = 0;
  
  public static void main(String[] args) {
    int anzahl;
    int staba = 1;
    int stabb = 2;
    int stabc = 3;
    anzahl = ConIn.readInt("Anzahl Scheiben: ");
    bewege(anzahl, staba, stabb, stabc);
  }
  
  static int bewege(int anzahl,int staba,int stabb,int stabc){
    int a = 0;
    if(anzahl > 0){
      bewege(anzahl - 1, staba, stabc, stabb);
      counter++;
      System.out.println(counter +  ". Verschiebe: Scheibe <" + anzahl + "> von " + staba + " nach " + stabc);
      bewege(anzahl - 1, stabb, staba, stabc);
    }
    return a;
  }
}

 

Revise this Paste

Children: 34516
Your Name: Code Language: