#include using namespace std; #include "prompt.h" #include "walk.h" // simulate two random walkers at once // Owen Astrachan, 6/29/96, modified 5/1/99 int main() { int numSteps = PromptRange("enter # steps",0,30000); RandomWalk frog(numSteps); // define two random walkers RandomWalk toad(numSteps); int samePadCount = 0; // # times at same location frog.Init(); // initialize both walks toad.Init(); while (frog.HasMore() && toad.HasMore()) { if (frog.Current() == toad.Current()) { samePadCount++; } frog.Next(); toad.Next(); } cout << "frog position = " << frog.Position() << endl; cout << "toad position = " << toad.Position() << endl; cout << "# times at same location = " << samePadCount << endl; return 0; }