<?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[Kann jemand das mal kontrollieren?]]></title><description><![CDATA[<p>Hallo,</p>
<p>über Hilfe wäre ich sehr dankbar.</p>
<p>Hier ist die Aufgabenstellung:<br />
Aufgabe:<br />
Schreiben Sie ein CPP Programm, das folgende Aufgabe erfüllt:<br />
- Allgemeine Ausgaben über den Programmierer (Name) und den Sinn des Programms (Überschrift)<br />
- Im Hauptprogramm wird ein Zufallsstring mit 20 Buchstaben erzeugt<br />
- Dieser Zufallsstring besteht nur aus Kleinbuchstaben<br />
- bei jedem Aufruf des Programms wird ein anderer Zufallsstring erzeugt<br />
- Das Hauptprogramm übergibt den Zufallsstring einer Funktion</p>
<p>Die Funktion hat folgende Aufgabe:<br />
- Die Anzahl der im Zufallsstring enthaltenen Vokale a oder e wird mit der Funktion ermittelt und ausgegeben<br />
- anschließend werden der Buchstabe i aus dem zufallsstring entfernt<br />
- dieser string wird an der Hauptprogramm zurückgegeben und dort ausgegeben</p>
<p>Und das ist mein Lösungsvorschlag:</p>
<pre><code>#include &lt;iostream&gt;
#include &lt;conio.h&gt;
#include &lt;string&gt;
#include &lt;time.h&gt;
#include &lt;stdlib.h&gt;

using namespace std;

void funktion(string h);

int funktion(string g);

int main(){
    srand( (unsigned)time( NULL ) );
    char h=rand()%26;

    int c,m;
    string e,f,k;

    char b[20];

     cout &lt;&lt; &quot;Hallo Ich bin ein Programm, von Schnicky geschrieben\n am 09.04.2008.\n Möchten Sie das Programm starten?\n&quot;;
    getline(cin,e);

    cout &lt;&lt; &quot;\n&quot; &quot;\n&quot;;

    cout &lt;&lt; &quot;Normale Ausgabe der einzelnen Buchstaben: &quot;;
    for(int i=0;i&lt;20;i++){    

                        h=rand()%26;

                        b[i]=h+97;

                        f[i]=b[i];

                        k=k+b[i];

                        cout &lt;&lt; b[i];    
    }

    m=funktion(f);

    cout &lt;&lt; &quot;\nEs gibt: &quot; &lt;&lt; m &lt;&lt; &quot; a und e in diesem Zufallsstring\n&quot;;

    cout &lt;&lt; &quot;\nProgramm beendet!!\n&quot;;

getch();
return 0;
}

int funktion(string g){

    int b=0;
                        for(int i=0;i&lt;20;i++){
                                                if(g[i]==97||g[i]==101){
                                                                      b=b+1;
                                                }
                                                else{
                                                                      continue;
                                                }
                        }

    return b;

}
</code></pre>
<p>Lieben Gruß,<br />
schnicky</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/210286/kann-jemand-das-mal-kontrollieren</link><generator>RSS for Node</generator><lastBuildDate>Tue, 13 Oct 2026 10:36:11 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/210286.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 09 Apr 2008 13:09:17 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Kann jemand das mal kontrollieren? on Wed, 09 Apr 2008 13:09:17 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>über Hilfe wäre ich sehr dankbar.</p>
<p>Hier ist die Aufgabenstellung:<br />
Aufgabe:<br />
Schreiben Sie ein CPP Programm, das folgende Aufgabe erfüllt:<br />
- Allgemeine Ausgaben über den Programmierer (Name) und den Sinn des Programms (Überschrift)<br />
- Im Hauptprogramm wird ein Zufallsstring mit 20 Buchstaben erzeugt<br />
- Dieser Zufallsstring besteht nur aus Kleinbuchstaben<br />
- bei jedem Aufruf des Programms wird ein anderer Zufallsstring erzeugt<br />
- Das Hauptprogramm übergibt den Zufallsstring einer Funktion</p>
<p>Die Funktion hat folgende Aufgabe:<br />
- Die Anzahl der im Zufallsstring enthaltenen Vokale a oder e wird mit der Funktion ermittelt und ausgegeben<br />
- anschließend werden der Buchstabe i aus dem zufallsstring entfernt<br />
- dieser string wird an der Hauptprogramm zurückgegeben und dort ausgegeben</p>
<p>Und das ist mein Lösungsvorschlag:</p>
<pre><code>#include &lt;iostream&gt;
#include &lt;conio.h&gt;
#include &lt;string&gt;
#include &lt;time.h&gt;
#include &lt;stdlib.h&gt;

using namespace std;

void funktion(string h);

int funktion(string g);

int main(){
    srand( (unsigned)time( NULL ) );
    char h=rand()%26;

    int c,m;
    string e,f,k;

    char b[20];

     cout &lt;&lt; &quot;Hallo Ich bin ein Programm, von Schnicky geschrieben\n am 09.04.2008.\n Möchten Sie das Programm starten?\n&quot;;
    getline(cin,e);

    cout &lt;&lt; &quot;\n&quot; &quot;\n&quot;;

    cout &lt;&lt; &quot;Normale Ausgabe der einzelnen Buchstaben: &quot;;
    for(int i=0;i&lt;20;i++){    

                        h=rand()%26;

                        b[i]=h+97;

                        f[i]=b[i];

                        k=k+b[i];

                        cout &lt;&lt; b[i];    
    }

    m=funktion(f);

    cout &lt;&lt; &quot;\nEs gibt: &quot; &lt;&lt; m &lt;&lt; &quot; a und e in diesem Zufallsstring\n&quot;;

    cout &lt;&lt; &quot;\nProgramm beendet!!\n&quot;;

getch();
return 0;
}

int funktion(string g){

    int b=0;
                        for(int i=0;i&lt;20;i++){
                                                if(g[i]==97||g[i]==101){
                                                                      b=b+1;
                                                }
                                                else{
                                                                      continue;
                                                }
                        }

    return b;

}
</code></pre>
<p>Lieben Gruß,<br />
schnicky</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1489080</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1489080</guid><dc:creator><![CDATA[schnicky]]></dc:creator><pubDate>Wed, 09 Apr 2008 13:09:17 GMT</pubDate></item><item><title><![CDATA[Reply to Kann jemand das mal kontrollieren? on Wed, 09 Apr 2008 13:12:32 GMT]]></title><description><![CDATA[<p>soweit ich weiß gab es hier im forum schon mal jemanden der haar genau denselben Thread eröffnet hat, mit haar genauer Aufgabenstellung, also frag doch mal lieber in deiner Klasse rum <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /> aber ansonsten, deine einrückung ist nicht gerade sehr vorteilhaft für den der Kontrollieren soll. Und weiterhin solltest du Strings auch in deinem zufallsgenerator benutzen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1489088</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1489088</guid><dc:creator><![CDATA[Firefighter]]></dc:creator><pubDate>Wed, 09 Apr 2008 13:12:32 GMT</pubDate></item><item><title><![CDATA[Reply to Kann jemand das mal kontrollieren? on Wed, 09 Apr 2008 13:16:55 GMT]]></title><description><![CDATA[<p>Ich komme hier her, weil ich einfach mal denke, dass mir hier jemand mehr helfen kann, als jemand aus meiner Klasse!!!<br />
Bekommt man eigentlich hier immer solch dumme Kommentare von dir?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1489096</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1489096</guid><dc:creator><![CDATA[schnicky]]></dc:creator><pubDate>Wed, 09 Apr 2008 13:16:55 GMT</pubDate></item><item><title><![CDATA[Reply to Kann jemand das mal kontrollieren? on Wed, 09 Apr 2008 13:20:43 GMT]]></title><description><![CDATA[<p>Das hat nix mit dummen Kommentaren zu tuen. Es ist nur so, wenn innerhalb von gut einer Woche hier der selbe Thread mit der selben Aufgabe 2 mal erstellt wird, is schon komisch?:D Aber um auf deine Aufgabe zurückzukommen, was verlangst du denn von uns?, Gibts Fehler?Wenn ja, welche. Stürzt dein Programm ab? Macht es nicht das was du möchtest, da musst du ein wenig genauer werden <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1489102</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1489102</guid><dc:creator><![CDATA[Firefighter]]></dc:creator><pubDate>Wed, 09 Apr 2008 13:20:43 GMT</pubDate></item><item><title><![CDATA[Reply to Kann jemand das mal kontrollieren? on Wed, 09 Apr 2008 13:25:36 GMT]]></title><description><![CDATA[<p>Ich wollte einfach nach Verbesserungsvorschläge fragen und das einfach kontrollieren lassen, ob das so ok ist.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1489106</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1489106</guid><dc:creator><![CDATA[schnicky]]></dc:creator><pubDate>Wed, 09 Apr 2008 13:25:36 GMT</pubDate></item><item><title><![CDATA[Reply to Kann jemand das mal kontrollieren? on Wed, 09 Apr 2008 13:30:48 GMT]]></title><description><![CDATA[<p>Wie Firefighter schon gesagt hat: du musst unbedingt vernünftig einrücken! 2-4 Zeichen sind optimal. So kann man das schlecht überblicken.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1489109</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1489109</guid><dc:creator><![CDATA[_matze]]></dc:creator><pubDate>Wed, 09 Apr 2008 13:30:48 GMT</pubDate></item><item><title><![CDATA[Reply to Kann jemand das mal kontrollieren? on Wed, 09 Apr 2008 13:34:43 GMT]]></title><description><![CDATA[<p>ok also folgendes:</p>
<pre><code class="language-cpp">char b[20];
</code></pre>
<p>da würde ich einen string nehmen</p>
<p>und ansonsten ordentlich einrücken, außerdem solltest du dir vieleicht noch vernünftige funktionsnamen aussuchen. Was mir noch wichtig wäre, das zwei gleich benannte funktionen nicht unterschiedliche datentypen(wenn man bei void von datentyp sprechen kann) zurück geben sollten.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1489115</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1489115</guid><dc:creator><![CDATA[Firefighter]]></dc:creator><pubDate>Wed, 09 Apr 2008 13:34:43 GMT</pubDate></item><item><title><![CDATA[Reply to Kann jemand das mal kontrollieren? on Wed, 09 Apr 2008 13:37:31 GMT]]></title><description><![CDATA[<p>Schon viel besser!</p>
<p>Danke für die Infos!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1489117</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1489117</guid><dc:creator><![CDATA[schnicky]]></dc:creator><pubDate>Wed, 09 Apr 2008 13:37:31 GMT</pubDate></item><item><title><![CDATA[Reply to Kann jemand das mal kontrollieren? on Wed, 09 Apr 2008 13:42:58 GMT]]></title><description><![CDATA[<p>und als vergleichsmöglichkeit, würde ich noch meine variante anbieten:D</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;time.h&gt;
#include &lt;string&gt;
#include &lt;algorithm&gt;
using namespace std;

struct vokale
{
    int vokal_i;
    int vokal_o;
    int vokal_e;
    int vokal_a;

    vokale()
    {
        vokal_i = 0;
        vokal_o = 0;
        vokal_e = 0;
        vokal_a = 0;
    }  

};

inline void vokale_finden(string wort,vokale &amp;vok)
{
    transform(wort.begin(),wort.end(),wort.begin(),static_cast&lt;int (*)(int)&gt;(tolower));

    for(int i = 0;i&lt;wort.length();i++)
    {
       switch(wort[i])
       {
           case 'i': vok.vokal_i++;
                     break;
           case 'a': vok.vokal_a++;
                     break;
           case 'e': vok.vokal_e++;
                     break;
           case 'o': vok.vokal_o++;
                     break;
       }
    }
}

int main()
{
    srand(unsigned(time(NULL)));

    vokale vok;

    string wort;
    string neues_wort;

    for(int i = 0;i&lt;50;i++)
    {
        wort = rand()%25+65;

        neues_wort = neues_wort + wort;
    }

    cout&lt;&lt;&quot;Unser Wort: &quot;&lt;&lt;neues_wort&lt;&lt;endl;

    vokale_finden(neues_wort,vok);

    cout&lt;&lt;&quot;Der Buchstabe 'i' wurde &quot;&lt;&lt;vok.vokal_i&lt;&lt;&quot; gefunden!&quot;&lt;&lt;endl;
    cout&lt;&lt;&quot;Der Buchstabe 'e' wurde &quot;&lt;&lt;vok.vokal_e&lt;&lt;&quot; gefunden!&quot;&lt;&lt;endl;
    cout&lt;&lt;&quot;Der Buchstabe 'o' wurde &quot;&lt;&lt;vok.vokal_o&lt;&lt;&quot; gefunden!&quot;&lt;&lt;endl;
    cout&lt;&lt;&quot;Der Buchstabe 'a' wurde &quot;&lt;&lt;vok.vokal_a&lt;&lt;&quot; gefunden!&quot;&lt;&lt;endl;

    return 0;

}
</code></pre>
<p>da muss man nun noch die löschung des buchstaben i vornehmen:D</p>
<p>EDIT: ohh meins nimmt ja nur große buchstaben bei der ausgabe...naja intern wandle ich sie aber in klein buchstaben um <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1489118</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1489118</guid><dc:creator><![CDATA[Firefighter]]></dc:creator><pubDate>Wed, 09 Apr 2008 13:42:58 GMT</pubDate></item><item><title><![CDATA[Reply to Kann jemand das mal kontrollieren? on Wed, 09 Apr 2008 13:48:57 GMT]]></title><description><![CDATA[<p>Hallo Schnicky,</p>
<p>einige Anmerkungen zum Programm:</p>
<p>- Die erste Benutzereingabe (&quot;Wollen Sie das Programm starten?&quot;) ist überflüssig. Zum einen is das Programm an dem Punkt schon gestartet worden, zum anderen startete ich das Programm woll kaum, wollte ich es nicht auch verwenden.</p>
<p>- Gewöhne Dir an, aussagekräftige Variablennamen zu verwenden. Einzelne Buchstaben verwendet man in der Regel nur bei Indexen (z.B. in Schleifen) oder wenn der Buchstabe für sich spricht (Koordinaten x, y, z; Radius r).</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
// #include &lt;conio.h&gt; .. Brauchst du nicht 1)
#include &lt;string&gt;
#include &lt;ctime&gt; // statt time.h
#include &lt;cstdlib&gt; // statt stdlib.h
</code></pre>
<ol>
<li>Eine Alternative zu getch() findest du hier im Forum (Konsolen-FAQ)</li>
</ol>
<p>Grüße... Heiko</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1489132</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1489132</guid><dc:creator><![CDATA[bwbg]]></dc:creator><pubDate>Wed, 09 Apr 2008 13:48:57 GMT</pubDate></item><item><title><![CDATA[Reply to Kann jemand das mal kontrollieren? on Wed, 09 Apr 2008 14:02:23 GMT]]></title><description><![CDATA[<p>Vielen Dank! Ich werde das mal ändern.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1489144</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1489144</guid><dc:creator><![CDATA[schnicky]]></dc:creator><pubDate>Wed, 09 Apr 2008 14:02:23 GMT</pubDate></item></channel></rss>