17 #include "DGtal/arithmetic/LighterSternBrocot.h"
22 using namespace DGtal;
26 void usage(
int,
char** argv )
28 std::cerr <<
"Usage: " << argv[ 0 ] <<
" <u_0> <u_1> ... <u_k>" << std::endl;
29 std::cerr <<
"\t - computes the fraction [u_0; u_1, ..., u_k] from its partial quotients." << std::endl;
35 int main(
int argc,
char** argv )
47 typedef SB::Fraction Fraction;
48 typedef Fraction::ConstIterator ConstIterator;
49 typedef Fraction::Value Value;
50 typedef std::back_insert_iterator< Fraction > OutputIterator;
55 OutputIterator itback = std::back_inserter( f );
56 for ( Quotient i = 1; i < argc; ++i)
58 Quotient u = atoll( argv[ i ] );
59 *itback++ = std::make_pair( u, i-1 );
61 std::cout <<
"z = " << f.p() <<
" / " << f.q() << std::endl;