C++ Aufgabe



  • Hallo
    komm mit der Aufgabe nicht weiter.
    kann mir vielleicht einer helfen

    Programm, das ein String mit Inhalt(Text beliebig) deklariert.
    Danach soll das Programm die Anzahl der Buchstaben a e i o u zählen.

    marco



  • Die Buchstaben nennt man auch Vokale 😉
    Die Anzahl jedes einzellnen Buchstabens?

    const std::string str("Mein Test String");
    std::size_t count_vowel[5]; /* a = 0, e = 1, i = 2, o = 3, u = 4 */
    std::fill(count_vowel, count_vowel + 5, 0);
    
    for (std::string::const_iterator(str.begin()); it != str.end(); ++it)
    {
        switch (*it)
        {
            case 'a': ++count_vowel[0]; break;
            case 'e': ++count_vowel[1]; break;
            case 'i': ++count_vowel[2]; break;
            case 'o': ++count_vowel[3]; break;
            case 'u': ++count_vowel[4]; break;
        }
    }
    

    ...



  • super danke
    das mit den buchstaben war mein Prof...



  • du machst auch für jeden die hausaufgabe 🙄


Anmelden zum Antworten