<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[small prob.]]></title><description><![CDATA[<p>mein programm soll die anzahl der buchstaben e ermitteln, aber das funktioniert irgendwie nicht, hoffentlich könnt ihr mir weiterhelfen.</p>
<pre><code>#include &lt;iostream&gt;
#include &lt;string&gt;
using namespace std;

int main()
{
    string satz;
    getline(cin, satz);
    int sum(0);
    int x = 0;
    double prozent(0);
    int z = satz.length();

    while(x!=z)
    {
        if(x==satz.find(&quot;e&quot;))
        {
            cout &lt;&lt; satz.find(&quot;e&quot;) &lt;&lt; endl;
            sum+=1;

        }

        satz.replace(x,x,&quot;x&quot;);
        x++;

    }
    cout &lt;&lt; z &lt;&lt; satz;
    prozent = sum/satz.length()*100;
    cout &lt;&lt; &quot;Es wurde &quot; &lt;&lt; sum &lt;&lt; &quot; mal e gefunden. Der prozentuale Anteil beträgt &quot; &lt;&lt; sum/satz.length() &lt;&lt;&quot;%.&quot; &lt;&lt; endl;

}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/334115/small-prob</link><generator>RSS for Node</generator><lastBuildDate>Sun, 26 Apr 2026 00:58:24 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/334115.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 23 Aug 2015 13:58:03 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to small prob. on Sun, 23 Aug 2015 13:58:03 GMT]]></title><description><![CDATA[<p>mein programm soll die anzahl der buchstaben e ermitteln, aber das funktioniert irgendwie nicht, hoffentlich könnt ihr mir weiterhelfen.</p>
<pre><code>#include &lt;iostream&gt;
#include &lt;string&gt;
using namespace std;

int main()
{
    string satz;
    getline(cin, satz);
    int sum(0);
    int x = 0;
    double prozent(0);
    int z = satz.length();

    while(x!=z)
    {
        if(x==satz.find(&quot;e&quot;))
        {
            cout &lt;&lt; satz.find(&quot;e&quot;) &lt;&lt; endl;
            sum+=1;

        }

        satz.replace(x,x,&quot;x&quot;);
        x++;

    }
    cout &lt;&lt; z &lt;&lt; satz;
    prozent = sum/satz.length()*100;
    cout &lt;&lt; &quot;Es wurde &quot; &lt;&lt; sum &lt;&lt; &quot; mal e gefunden. Der prozentuale Anteil beträgt &quot; &lt;&lt; sum/satz.length() &lt;&lt;&quot;%.&quot; &lt;&lt; endl;

}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2465204</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2465204</guid><dc:creator><![CDATA[C++Nab]]></dc:creator><pubDate>Sun, 23 Aug 2015 13:58:03 GMT</pubDate></item><item><title><![CDATA[Reply to small prob. on Sun, 23 Aug 2015 14:13:29 GMT]]></title><description><![CDATA[<p>Die Funktion find gibt die erste Position an der ein 'e' gefunden wird zurück. Du willst aber eigentlich testen ob an der aktuellen Position ein 'e' steht. Also irgendwie sowas:</p>
<pre><code>if(satz[x] == 'e')
{
    cout &lt;&lt; x &lt;&lt; endl;
    sum+=1;
}
</code></pre>
<p>Dazu ist dein replace glaube ich falsch und eine for Schleife würde sich hier anbieten.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2465206</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2465206</guid><dc:creator><![CDATA[sebi707]]></dc:creator><pubDate>Sun, 23 Aug 2015 14:13:29 GMT</pubDate></item><item><title><![CDATA[Reply to small prob. on Sun, 23 Aug 2015 14:42:01 GMT]]></title><description><![CDATA[<p>Danke das hat mir weitergeholfen, habs mit der for schleife ersetzt, hatte mindfuck bei arrays aber habs verstanden, naja aber mein programm hat noch einen fehler. Es zeigt die ganze zeit 0% an.</p>
<pre><code>#include &lt;iostream&gt;
#include &lt;string&gt;
using namespace std;

int main()
{
    string satz;
    getline(cin, satz);
    int sum(0);
    double prozent(0);
    int z = satz.length();

    for(int x=0;x!=z;x++)
    {
        if(satz[x] == 'e')
        {
            sum+=1;

        }

    }
    prozent=sum/satz.length()*100;
    cout &lt;&lt; &quot;Es wurde &quot; &lt;&lt; sum &lt;&lt; &quot; mal e gefunden. Der prozentuale Anteil beträgt &quot; &lt;&lt; prozent&lt;&lt;&quot;%.&quot; &lt;&lt; endl;

}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2465209</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2465209</guid><dc:creator><![CDATA[C++Nab]]></dc:creator><pubDate>Sun, 23 Aug 2015 14:42:01 GMT</pubDate></item><item><title><![CDATA[Reply to small prob. on Sun, 23 Aug 2015 14:42:51 GMT]]></title><description><![CDATA[<p><a href="http://en.cppreference.com/w/cpp/algorithm/count" rel="nofollow">http://en.cppreference.com/w/cpp/algorithm/count</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2465210</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2465210</guid><dc:creator><![CDATA[Furble Wurble]]></dc:creator><pubDate>Sun, 23 Aug 2015 14:42:51 GMT</pubDate></item><item><title><![CDATA[Reply to small prob. on Sun, 23 Aug 2015 14:44:21 GMT]]></title><description><![CDATA[<p>Hint: In C++ ist 5/7 gleich 0 (Stichwort: Integerdivision).</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2465211</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2465211</guid><dc:creator><![CDATA[youshallnotdivide]]></dc:creator><pubDate>Sun, 23 Aug 2015 14:44:21 GMT</pubDate></item><item><title><![CDATA[Reply to small prob. on Sun, 23 Aug 2015 14:46:04 GMT]]></title><description><![CDATA[<p>habs aber double gesetzt<br />
oder muss ich eine template dafür machen?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2465212</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2465212</guid><dc:creator><![CDATA[C++Nab]]></dc:creator><pubDate>Sun, 23 Aug 2015 14:46:04 GMT</pubDate></item><item><title><![CDATA[Reply to small prob. on Sun, 23 Aug 2015 14:49:44 GMT]]></title><description><![CDATA[<p>sum ist ein Integer und satz.length() auch. Was prozent für einen Typ hat, spielt da keine Rolle. Wenn beide Operanden eine Ganzzahl sind, wird Integerdivsion gemacht.</p>
<p>Du musst also eine der beiden Operanden in einen double casten.</p>
<p>PS: Wieso initialisierst du deine Variablen mit runden Klammern???</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2465213</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2465213</guid><dc:creator><![CDATA[youshallnotdivide]]></dc:creator><pubDate>Sun, 23 Aug 2015 14:49:44 GMT</pubDate></item><item><title><![CDATA[Reply to small prob. on Sun, 23 Aug 2015 15:18:11 GMT]]></title><description><![CDATA[<p>hab ich mir angewöhnt diese schreibweise find ich irgendwie übersichtilicher mit den klammern, aber wie fix ich jetzt mein problem?</p>
<p>________________________________________________________</p>
<p>nvm gefixed <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f603.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--grinning_face_with_big_eyes"
      title=":D"
      alt="😃"
    /><br />
danke für die hilfe</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2465214</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2465214</guid><dc:creator><![CDATA[C++Nab]]></dc:creator><pubDate>Sun, 23 Aug 2015 15:18:11 GMT</pubDate></item><item><title><![CDATA[Reply to small prob. on Mon, 24 Aug 2015 11:35:02 GMT]]></title><description><![CDATA[<p>Hi,</p>
<p>so wie youshallnotdivide es bereits beschrieben hatte.</p>
<p>Caste einen der Integerwerte in einen double, z.B. so:</p>
<pre><code>prozent=(double)sum/satz.length()*100;
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2465333</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2465333</guid><dc:creator><![CDATA[CastingShow]]></dc:creator><pubDate>Mon, 24 Aug 2015 11:35:02 GMT</pubDate></item></channel></rss>