Info2/25.6.3.c
2025-05-01 19:15:53 +02:00

38 lines
1.2 KiB
C

#include <stdio.h>
#include <string.h>
int finde_zahlwort(char *wort) {
if (strcasestr(wort, "eins")) return 1;
if (strcasestr(wort, "zwei")) return 2;
if (strcasestr(wort, "drei")) return 3;
if (strcasestr(wort, "vier")) return 4;
if (strcasestr(wort, "fünf")) return 5;
if (strcasestr(wort, "sechs")) return 6;
if (strcasestr(wort, "sieben")) return 7;
if (strcasestr(wort, "acht")) return 8;
if (strcasestr(wort, "neun")) return 9;
if (strcasestr(wort, "zehn")) return 10;
if (strcasestr(wort, "elf")) return 11;
if (strcasestr(wort, "zwölf")) return 12;
return 0;
}
int main() {
char *worte[] = {
"Endreim", "Kurzweil", "Nachtfalter", "Wohnviertel", "Neunauge",
"Weinstein", "Erdreich", "Achtung", "Segelflieger", "Pfalzwein",
"Radreifen", "Gehhelfer", "Leinsamen"
};
int summe = 0;
for (int i = 0; i < sizeof(worte)/sizeof(worte[0]); i++) {
int wert = finde_zahlwort(worte[i]);
if (wert > 0)
printf("%s: ... %d\n", worte[i], wert);
summe += wert;
}
printf("------------------------------\n");
printf("Summe: %d\n", summe);
return 0;
}