Hanoy - cout<<"disk

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
#include<iostream.h> # void towers(int disks,int source,int destination,int auxiliary) { if(disks == 1) { cout<<"disk "<<disks<<"from"<<source<<"-->"<<destination<<endl; return; } towers(disks - 1,source,auxiliary,destination);
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: cout<<"disk "<<disks<<"from"<<source<<"-->"<<destination<<endl; towers(disks - 1,auxiliary,destination,source); } void main() { int ndisks; cout<<"Enter the number of disks:=";cin>>ndisks; towers(ndisks,1,3,2); }...
View Full Document

This note was uploaded on 11/21/2010 for the course COMPUTER S 002 taught by Professor Ramtinkhosravi during the Spring '10 term at Amirkabir University of Technology.

Ask a homework question - tutors are online