253#include <tclap/CmdLine.h>
257using namespace Aleph;
261 for (
unsigned i = 0; i < s; i++)
278 printf(
"Step size must be >= 1\n");
282 for (
unsigned i = 1; i <= num_personas; i++)
286 for (; num_personas > 1; num_personas--)
293 printf(
"\nSurvivor is %u\n", list.
get_first());
299 TCLAP::CmdLine
cmd(
"Josephus problem",
' ',
"1.0");
301 TCLAP::ValueArg<unsigned> numPerArg(
"n",
"num-persons",
303 false, 20,
"unsigned");
306 TCLAP::ValueArg<unsigned> pasoArg(
"p",
"paso",
308 false, 7,
"unsigned");
311 cmd.parse(argc, argv);
313 unsigned numPer = numPerArg.getValue(),
314 paso = pasoArg.getValue();
317 }
catch (TCLAP::ArgException &e) {
318 std::cerr <<
"error: " << e.error() <<
" for arg " << e.argId() << std::endl;
bool has_curr() const noexcept
Return true if the iterator has current item.
T & get_curr() const
Return the current item; throw overflow_error if there is no current item.
T del()
Remove from the list the current node and move the iterator one position forward.
void reset_first() noexcept
Reset the iterator to the first item.
void next()
Move the iterator one item forward.
Dynamic doubly linked list with O(1) size and bidirectional access.
T & get_first()
Return a modifiable reference to first item in the list.
T & append(const T &item)
Append a copied item at the end of the list.
void avanceItor(DynDlist< unsigned >::Iterator &itor, unsigned s)
void orden_ejecucion(unsigned num_personas, unsigned paso)
Main namespace for Aleph-w library functions.
Dynamic doubly linked list implementation.