<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress/2.0.5" -->
<rss version="2.0" 
	xmlns:content="http://purl.org/rss/1.0/modules/content/">
<channel>
	<title>Comments on: The Greedy algorithm/method</title>
	<link>http://www.datastructures.info/the-greedy-algorithm/</link>
	<description>Data structures, algorithms, e-books, usefull code and so on...</description>
	<pubDate>Thu, 20 Nov 2008 20:14:08 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.0.5</generator>

	<item>
		<title>by: Gaspos 2</title>
		<link>http://www.datastructures.info/the-greedy-algorithm/#comment-55</link>
		<pubDate>Mon, 12 Mar 2007 19:35:40 +0000</pubDate>
		<guid>http://www.datastructures.info/the-greedy-algorithm/#comment-55</guid>
					<description>@ Gaspos: You can use the online HTML encoder to encode your programme's source code and then post it here. This form obviously doesn't escape the text and displays it as HTML in browser. Let me check:

alert('Yep, it does not escape it!')

Cheers.</description>
		<content:encoded><![CDATA[<p>@ Gaspos: You can use the online HTML encoder to encode your programme&#8217;s source code and then post it here. This form obviously doesn&#8217;t escape the text and displays it as HTML in browser. Let me check:</p>
<p>alert(&#8217;Yep, it does not escape it!&#8217;)</p>
<p>Cheers.
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: carmen</title>
		<link>http://www.datastructures.info/the-greedy-algorithm/#comment-54</link>
		<pubDate>Sun, 11 Mar 2007 18:34:35 +0000</pubDate>
		<guid>http://www.datastructures.info/the-greedy-algorithm/#comment-54</guid>
					<description>i tried to undarstand gaspos's method...but i can't see why doesn't he increase(/modify) "i".....
..int i = 1 ;
….i ;//was it   i; ?
or the double   character is interpreted too? :)</description>
		<content:encoded><![CDATA[<p>i tried to undarstand gaspos&#8217;s method&#8230;but i can&#8217;t see why doesn&#8217;t he increase(/modify) &#8220;i&#8221;&#8230;..<br />
..int i = 1 ;<br />
….i ;//was it   i; ?<br />
or the double   character is interpreted too? <img src='http://www.datastructures.info/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Gaspos</title>
		<link>http://www.datastructures.info/the-greedy-algorithm/#comment-50</link>
		<pubDate>Tue, 06 Mar 2007 11:27:34 +0000</pubDate>
		<guid>http://www.datastructures.info/the-greedy-algorithm/#comment-50</guid>
					<description>It's me again !
I understood : the character inferior is interpreted !
So here a new version with inferior replaced with '^' :

#include ^iostream&#62;
using namespace std ;

void main ()
..{
..int numerator,denominator ;
..
..cout ^^ "Enter numerator and then denominator" ^^ endl ;
..cin &#62;&#62; numerator &#62;&#62; denominator ;

..int i = 1 ;
..// factor == factor_num/factor_den 
..int factor_num = numerator ;
..int factor_den = denominator ;
..do  {
....// temp == 1 / i ==&#62; factor &#62;= temp 
....// ==  factor_num/factor_den &#62;= 1/i
....// ==  factor_num*i &#62;= factor_den
....i   ;
....if (factor_num*i &#62;= factor_den)
......{
......cout ^^ "   1/" ^^ i ;
......// factor - 1/i 
......// == factor_num/factor_den - 1/i 
......// == (factor_num*i - factor_den)/(factor_den*i)
......factor_num = factor_num*i - factor_den ;
......factor_den = factor_den*i ;
......}
....} 
....while ( factor_num &#62; 0 ) ;
..}

I had to put '.' instead of ' ' to keep indentation.
Pleace replace '.' with ' ' 
and '^' with inferior sign before to compile !

Gaspos</description>
		<content:encoded><![CDATA[<p>It&#8217;s me again !<br />
I understood : the character inferior is interpreted !<br />
So here a new version with inferior replaced with &#8216;^&#8217; :</p>
<p>#include ^iostream&gt;<br />
using namespace std ;</p>
<p>void main ()<br />
..{<br />
..int numerator,denominator ;<br />
..<br />
..cout ^^ &#8220;Enter numerator and then denominator&#8221; ^^ endl ;<br />
..cin &gt;&gt; numerator &gt;&gt; denominator ;</p>
<p>..int i = 1 ;<br />
..// factor == factor_num/factor_den<br />
..int factor_num = numerator ;<br />
..int factor_den = denominator ;<br />
..do  {<br />
&#8230;.// temp == 1 / i ==&gt; factor &gt;= temp<br />
&#8230;.// ==  factor_num/factor_den &gt;= 1/i<br />
&#8230;.// ==  factor_num*i &gt;= factor_den<br />
&#8230;.i   ;<br />
&#8230;.if (factor_num*i &gt;= factor_den)<br />
&#8230;&#8230;{<br />
&#8230;&#8230;cout ^^ &#8221;   1/&#8221; ^^ i ;<br />
&#8230;&#8230;// factor - 1/i<br />
&#8230;&#8230;// == factor_num/factor_den - 1/i<br />
&#8230;&#8230;// == (factor_num*i - factor_den)/(factor_den*i)<br />
&#8230;&#8230;factor_num = factor_num*i - factor_den ;<br />
&#8230;&#8230;factor_den = factor_den*i ;<br />
&#8230;&#8230;}<br />
&#8230;.}<br />
&#8230;.while ( factor_num &gt; 0 ) ;<br />
..}</p>
<p>I had to put &#8216;.&#8217; instead of &#8216; &#8216; to keep indentation.<br />
Pleace replace &#8216;.&#8217; with &#8216; &#8216;<br />
and &#8216;^&#8217; with inferior sign before to compile !</p>
<p>Gaspos
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Gaspos</title>
		<link>http://www.datastructures.info/the-greedy-algorithm/#comment-49</link>
		<pubDate>Tue, 06 Mar 2007 11:22:38 +0000</pubDate>
		<guid>http://www.datastructures.info/the-greedy-algorithm/#comment-49</guid>
					<description>Ooops ! the copy/paste did not worked proprely !
I try once more :


#include 
using namespace std ;

void main ()
..{
..int numerator,denominator ;
..
..cout &#62; numerator &#62;&#62; denominator ;

..int i = 1 ;
..// factor == factor_num/factor_den 
..int factor_num = numerator ;
..int factor_den = denominator ;
..do  {
....// temp == 1 / i ==&#62; factor &#62;= temp 
....//   factor_num/factor_den &#62;= 1/i
....//   factor_num*i &#62;= factor_den
....i   ;
....if (factor_num*i &#62;= factor_den)
......{
......cout  0 ) ;
..}

I had to put '.' instead of ' ' to keep indentation.
Pleace replace '.' with ' ' before to compile !

Gaspos</description>
		<content:encoded><![CDATA[<p>Ooops ! the copy/paste did not worked proprely !<br />
I try once more :</p>
<p>#include<br />
using namespace std ;</p>
<p>void main ()<br />
..{<br />
..int numerator,denominator ;<br />
..<br />
..cout &gt; numerator &gt;&gt; denominator ;</p>
<p>..int i = 1 ;<br />
..// factor == factor_num/factor_den<br />
..int factor_num = numerator ;<br />
..int factor_den = denominator ;<br />
..do  {<br />
&#8230;.// temp == 1 / i ==&gt; factor &gt;= temp<br />
&#8230;.//   factor_num/factor_den &gt;= 1/i<br />
&#8230;.//   factor_num*i &gt;= factor_den<br />
&#8230;.i   ;<br />
&#8230;.if (factor_num*i &gt;= factor_den)<br />
&#8230;&#8230;{<br />
&#8230;&#8230;cout  0 ) ;<br />
..}</p>
<p>I had to put &#8216;.&#8217; instead of &#8216; &#8216; to keep indentation.<br />
Pleace replace &#8216;.&#8217; with &#8216; &#8216; before to compile !</p>
<p>Gaspos
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Gaspos</title>
		<link>http://www.datastructures.info/the-greedy-algorithm/#comment-48</link>
		<pubDate>Tue, 06 Mar 2007 11:16:04 +0000</pubDate>
		<guid>http://www.datastructures.info/the-greedy-algorithm/#comment-48</guid>
					<description>I suggest a more accurate version using fractions instead of floating :

#include 
using namespace std ;

void main ()
    {
    int numerator,denominator ;
    
    cout &#62; numerator &#62;&#62; denominator ;

    int i = 1 ;
    // factor == factor_num/factor_den 
    int factor_num = numerator ;
    int factor_den = denominator ;
    do  {
        // temp == 1 / i ==&#62; factor &#62;= temp  factor_num/factor_den &#62;= 1/i  factor_num*i &#62;= factor_den
        i   ;
        if (factor_num*i &#62;= factor_den)
            {
            cout  0 ) ;
    }

Thanks for you site !
Gaspos</description>
		<content:encoded><![CDATA[<p>I suggest a more accurate version using fractions instead of floating :</p>
<p>#include<br />
using namespace std ;</p>
<p>void main ()<br />
    {<br />
    int numerator,denominator ;</p>
<p>    cout &gt; numerator &gt;&gt; denominator ;</p>
<p>    int i = 1 ;<br />
    // factor == factor_num/factor_den<br />
    int factor_num = numerator ;<br />
    int factor_den = denominator ;<br />
    do  {<br />
        // temp == 1 / i ==&gt; factor &gt;= temp  factor_num/factor_den &gt;= 1/i  factor_num*i &gt;= factor_den<br />
        i   ;<br />
        if (factor_num*i &gt;= factor_den)<br />
            {<br />
            cout  0 ) ;<br />
    }</p>
<p>Thanks for you site !<br />
Gaspos
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Richard Domander</title>
		<link>http://www.datastructures.info/the-greedy-algorithm/#comment-43</link>
		<pubDate>Wed, 14 Feb 2007 21:25:32 +0000</pubDate>
		<guid>http://www.datastructures.info/the-greedy-algorithm/#comment-43</guid>
					<description>I had the same problem with the code as "C" did (though Java/Eclipse). I believe the program doesn't work properly because the computer rounds doubles. Even in this example (6/7) the error grows big enough to cause false results.</description>
		<content:encoded><![CDATA[<p>I had the same problem with the code as &#8220;C&#8221; did (though Java/Eclipse). I believe the program doesn&#8217;t work properly because the computer rounds doubles. Even in this example (6/7) the error grows big enough to cause false results.
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: refikh</title>
		<link>http://www.datastructures.info/the-greedy-algorithm/#comment-9</link>
		<pubDate>Mon, 15 Jan 2007 17:01:26 +0000</pubDate>
		<guid>http://www.datastructures.info/the-greedy-algorithm/#comment-9</guid>
					<description>Hi C,
download the Dev C   compiler and try it! You can find the compiler on http://www.bloodshed.net/devcpp.html :) 

Good luck. Let me know if you have some trouble!</description>
		<content:encoded><![CDATA[<p>Hi C,<br />
download the Dev C   compiler and try it! You can find the compiler on <a href="http://www.bloodshed.net/devcpp.html" rel="nofollow">http://www.bloodshed.net/devcpp.html</a> <img src='http://www.datastructures.info/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  </p>
<p>Good luck. Let me know if you have some trouble!
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: C</title>
		<link>http://www.datastructures.info/the-greedy-algorithm/#comment-8</link>
		<pubDate>Mon, 15 Jan 2007 16:08:12 +0000</pubDate>
		<guid>http://www.datastructures.info/the-greedy-algorithm/#comment-8</guid>
					<description>hey it's not working on my borland 3.1 he show my 2 3 43 and 1807</description>
		<content:encoded><![CDATA[<p>hey it&#8217;s not working on my borland 3.1 he show my 2 3 43 and 1807
</p>
]]></content:encoded>
				</item>
</channel>
</rss>
