الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

towers of hanio

مغلق
بدأه programmer_st في 28 نوفمبر 2003 · 4 رد · 1,391 مشاهدة · في JavaSE
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

السلام عليكم

ممكن تساعدوني بكتابة برنامج Tower of Hanoi

شكرا لكم

وكل عام و أنت بخير

#2

عن ايه بالظبت البرنامج ياريت لو توضح اكتر؟؟؟؟

ahabdeen.jpg

<marquee>

مش موجود بصفة دايمة للامتحانات

</marquee>

#3

The initial stack has number of disks threaded onto one peg and arranged from bottom to top by decreasing size, attempting to move the stack from this peg to a second peg under constraints that exactly one disk is moved at a time and at no time may a larger disk be placed above a smaller disk , a third peg is available for temporarily holding disks.

Please send to me the recursive method code to move the number of disks from peg1 to peg3

و شكرا كثيرا أي اقتراح

و إذا أرتم أي توضيح أنا مستعد

#4

import java.io.*;

public class hanoi

{

public static void main(String[] args) throws IOException

{

BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));

int disks;

System.out.println("Enter number of disks: ");

disks = Integer.parseInt(stdin.readLine());

doHanoi(disks, "1", "3", "2");

}

public static void doHanoi(int disks, String start, String end, String temp)

{

if (disks >= 1)

{

doHanoi(disks - 1, start, temp, end);

System.out.println("Move 1 disk from " + start + " to " + end);

doHanoi(disks - 1, temp, end, start);

}

}

}

#5

شكرا

و جزاك الله كل خير

هذا الموضوع مغلق.

مواضيع مشابهة