C :: Aufgabe #95 :: Lösung #2

2 Lösungen Lösungen öffentlich
#95

Text in Löffelsprache konvertieren

Anfänger - C von Veigar - 16.12.2015 um 19:05 Uhr
Schreibe ein Script welches einen Text entgegen nimmt und ihn in Löffelsprache konvertiert!
(Löffelsprache: "Geheimsprache" die oft von Kindern benutzt wird, und die dadurch gebildet wird das an jeden Vokal (Selbstlaut) „lew" und dann noch einmal der Vokal gehängt wird. zum Beispiel "Ich bin klug!"-->"Ilewich bilewin klulewug!")
#2
vote_ok
von kathleenw (3600 Punkte) - 16.07.2020 um 09:35 Uhr
Quellcode ausblenden C-Code
#include <stdio.h>
#include <stdlib.h>

int main(void)
{
    int groesse, stelle_loeffel,i;
    
    groesse = 30;
    stelle_loeffel = 0;
    i=0;
    char text[groesse];
    char loeffel[groesse*4];
    
    printf("Welcher Satz soll in Löffelsprache umgewandelt werden?\n");
    fgets(text,groesse,stdin);
    
    while (text[i]!='\0')
    {
        if (text[i]=='i' || text[i]=='I' || text[i]=='a' || text[i]=='A' || text[i]=='e' || text[i]=='E' || text[i]=='o' || text[i]=='O' || text[i]=='u' || text[i]=='U') {
            loeffel[stelle_loeffel] = text[i];
            loeffel[stelle_loeffel+1] = 'l';
            loeffel[stelle_loeffel+2] = 'e';
            loeffel[stelle_loeffel+3] = 'w';
            loeffel[stelle_loeffel+4] = text[i];
            stelle_loeffel = stelle_loeffel + 5;
        }
        else {
            loeffel[stelle_loeffel]= text[i];
            stelle_loeffel++;
        }
        i++;
    }
    
    for (i=0;i<=stelle_loeffel;i++)
    {
        printf("%c", loeffel[i]);
    }
    printf("\n");
    return EXIT_SUCCESS;
}

Kommentare:

Für diese Lösung gibt es noch keinen Kommentar

Bitte melden Sie sich an um eine Kommentar zu schreiben.
Kommentar schreiben