I need to make a towers of hanoi program using vectors. the code I came up with works fine without the vectors. I have no clue how to make it work with vectors. any help?
thanks

#include <iostream>
#include <vector>
using namespace std;

void towers( vector <int> &disks, int start, int end, int temp)
{
	if( disks == 1 )  // base case
		cout <<start <<"---> "<< end <<"\n";

		else //recursion step
		{
			//move disks - 1 disk from start to temp
		    towers(disks - 1, start, temp, end);
			
			//move last disk from start to end
			cout<<start<< "---> "<< end << "\n";
			
			//move disks - 1 disk from temp to end
			towers(disks - 1, temp, end, start);
			
		} // end else
} // end function towers

int main() 
{
	int n;
    cout<<"Enter number of Discs: ";
	cin >> n;
    towers(n, 1, 3, 2);
    return 0;
}

wow, 123 views, no response, wow...

wow, 123 views, no response, wow...

No response? Really? What about

Do You Have any idea on how a vector works?

It seems the no response was on your end, bucko.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.