#include#include class Tower { public: int Holding; apstack Pieces; void Leaving(apvector &, int); }; void Tower::Leaving(apvector &Towers, int To) { if(!Pieces.isEmpty()) { Pieces.pop(Holding); if(Towers[To].Pieces.isEmpty()) { Towers[To].Pieces.push(Holding); } else { if(Towers[To].Pieces.top() &Towers) { int From, To; do { cout << "Enter tower to take piece from and tower to put piece on: "; cin >> From >> To; }while(From<1||To<1||From>3||To>3); Towers[From].Leaving(Towers, To); } void Display(apvector &Towers, int Num) { for(int Blank=1; Blank<4; Blank++) { int Temp; apstack Temporary; apvector NumGreaterThan(Num, 0); while(!Towers[Blank].Pieces.isEmpty()) { Towers[Blank].Pieces.pop(Temp); for(int I=0; I I) { NumGreaterThan[I]++; } } Temporary.push(Temp); } while(!Temporary.isEmpty()) { Temporary.pop(Temp); Towers[Blank].Pieces.push(Temp); } cout << " |" << endl; for(int D=Num-1; D>=0; D--) { cout << " |"; for(int E=0; E Towers(4); int Num; cout << "Number of pieces: "; cin >> Num; int New=Num; for( ; New>0; New--) { Towers[1].Pieces.push(New); } while(1) { system("cls"); Display(Towers, Num); if(Towers[3].Pieces.length()==Num) { cout << "You Win!!!\n"; exit(0); } Process(Towers); } }
Text file Source (historic): geocities.com/thepastavandal
(to report bad content: archivehelp @ gmail)
|
|
|
|
|